-
Notifications
You must be signed in to change notification settings - Fork 15
/
.travis.yml
53 lines (42 loc) · 2.63 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
sudo: required
language: bash
services:
- docker
env:
global:
- SONARQUBE_VERSION="lts"
matrix:
include:
- env: DB_NAME="mysql" DB_VERSION="5.7" DB_LOG="ready for connections" COMPOSE_FILE="$TRAVIS_BUILD_DIR/SonarOnDocker/docker-compose-mysql.yml" SONARQUBE_VERSION="7.7-community"
- env: DB_NAME="postgres" DB_VERSION="10" DB_LOG="ready to accept connections" COMPOSE_FILE="$TRAVIS_BUILD_DIR/SonarOnDocker/docker-compose-postgres.yml"
git:
depth: 1
install:
- git clone --branch=$TRAVIS_BRANCH https://github.com/thyrlian/SonarOnDocker.git
before_script:
- sudo sysctl -w vm.max_map_count=262144
script:
- docker pull sonarqube:$SONARQUBE_VERSION
- docker pull $DB_NAME:$DB_VERSION
- sed -i "s/image\:\ sonarqube/image\:\ sonarqube\:$SONARQUBE_VERSION/g" $COMPOSE_FILE
- sed -i "s/image\:\ $DB_NAME/image\:\ $DB_NAME\:$DB_VERSION/g" $COMPOSE_FILE
- docker-compose -f $COMPOSE_FILE run --service-ports -d sonarqube
- for ((i=1; i<=300; i++)) { sleep 1; if docker ps -aqf "ancestor=$DB_NAME:$DB_VERSION" | xargs docker logs 2>&1 | grep "$DB_LOG" &> /dev/null && docker ps -aqf "ancestor=sonarqube:$SONARQUBE_VERSION" | xargs docker logs 2>&1 | grep "SonarQube is up" &> /dev/null; then return 0; fi } && return 1
- curl -s -w "%{http_code}\\n" "http://localhost:9000/" -o /dev/null | grep "200\|302" &> /dev/null
after_success:
- echo "☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑"
- echo "---------- Docker orchestration succeeded! ----------"
- echo "☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑☑"
after_failure:
- echo "☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒"
- echo "---------- Docker orchestration failed! ----------"
- echo "☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒☒"
after_script:
- echo "---------- DB logs ----------"
- echo "=================================================="
- docker ps -aqf "ancestor=$DB_NAME:$DB_VERSION" | xargs docker logs 2>&1
- echo "=================================================="
- echo "---------- SonarQube logs ----------"
- echo "=================================================="
- docker ps -aqf "ancestor=sonarqube:$SONARQUBE_VERSION" | xargs docker logs 2>&1
- echo "=================================================="