|
1 | 1 | language: java
|
2 | 2 | jdk: oraclejdk8
|
3 |
| - |
4 |
| -# Define the services to use |
5 | 3 | services:
|
6 |
| - - docker |
7 |
| - |
| 4 | +- docker |
8 | 5 | before_install:
|
9 |
| - - sudo service mysql stop |
10 |
| - - docker pull takimatraining/devops-training-db |
11 |
| - - docker run -d -p 127.0.0.1:3306:3306 takimatraining/devops-training-db |
12 |
| - |
13 |
| -# Run Unit Test and Integration Tests |
| 6 | +- openssl aes-256-cbc -K $encrypted_f575727d0541_key -iv $encrypted_f575727d0541_iv |
| 7 | + -in travis_deploy_rsa.enc -out /tmp/travis_deploy_rsa -d |
| 8 | +- chmod 600 /tmp/travis_deploy_rsa |
| 9 | +- eval "$(ssh-agent -s)" |
| 10 | +- ssh-add /tmp/travis_deploy_rsa |
| 11 | +- echo -e "Host $SERVER_HOST\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config |
| 12 | +- sudo service mysql stop |
| 13 | +- docker pull takimatraining/devops-training-db |
| 14 | +- docker run -d -p 127.0.0.1:3306:3306 takimatraining/devops-training-db |
14 | 15 | script:
|
15 |
| - - mvn verify |
| 16 | +- | |
| 17 | + mvn clean install sonar:sonar \ |
| 18 | + -Dsonar.projectKey=<SONAR_PROJECT_KEY> \ |
| 19 | + -Dsonar.organization=<SONAR_ORGANISATION_KEY> \ |
| 20 | + -Dsonar.host.url=https://sonarcloud.io \ |
| 21 | + -Dsonar.login=$SONAR_TOKEN |
| 22 | +
|
| 23 | +# Deploy updated container over ssh |
| 24 | +deploy: |
| 25 | + provider: script |
| 26 | + script: ssh -i /tmp/travis_deploy_rsa $DEPLOY_USER@$SERVER_HOST "sudo docker pull $IMAGE_NAME:$TAG && sudo docker rm -f app || true && sudo docker run -d --network net -p 80:8080 --name app $IMAGE_NAME:$TAG" |
| 27 | + on: |
| 28 | + branch: master |
16 | 29 |
|
17 |
| -# Cache the .m2 folder to prevent redownloading dependencies on each build |
18 | 30 | cache:
|
19 | 31 | directories:
|
20 | 32 | - "$HOME/.m2/repository"
|
21 |
| - |
22 |
| -# Environment variables are strings (double quotes) |
23 |
| -# Example: |
24 |
| -# - secure: "DpR1th9rZvLMX0......" |
25 | 33 | env:
|
26 | 34 | global:
|
27 |
| - - secure: <ENCRYPTED_TOKEN> |
28 |
| - |
29 |
| -# The pipe (|) is useful to create multiline scripts |
30 |
| -script: |
31 |
| - - | |
32 |
| - mvn clean install sonar:sonar \ |
33 |
| - -Dsonar.projectKey=<SONAR_PROJECT_KEY> \ |
34 |
| - -Dsonar.organization=<SONAR_ORGANISATION_KEY> \ |
35 |
| - -Dsonar.host.url=https://sonarcloud.io \ |
36 |
| - -Dsonar.login=$SONAR_TOKEN |
37 |
| -
|
38 |
| -# Send an email to the commiter if the pipeline failed at some point |
| 35 | + - secure: "<ENCRYPTED_TOKEN>" |
39 | 36 | notifications:
|
40 | 37 | email:
|
41 | 38 | on_failure: always
|
0 commit comments