|
1 | 1 | node {
|
2 |
| - try{ |
3 |
| - // slackSend channel: '#integration', message: "started ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)", teamDomain: 'agileworks-tw', token: 'JhXFKEl6cBFoQ4v52BEJw9Mr' |
4 |
| - |
5 |
| - stage 'checkout project' |
6 |
| - //git url: 'https://github.com/agileworks-tw/spring-boot-sample.git' |
7 |
| - checkout scm |
8 | 2 |
|
9 |
| - stage 'check env' |
| 3 | + stage 'checkout project' |
| 4 | + //git url: 'https://github.com/agileworks-tw/spring-boot-sample.git' |
| 5 | + checkout scm |
| 6 | + stage 'check docker env' |
10 | 7 |
|
11 |
| - sh "mvn -v" |
12 |
| - sh "java -version" |
| 8 | + sh "docker -v" |
| 9 | + sh "docker-compose -v" |
| 10 | + sh "docker ps" |
| 11 | + sh "make start-docker-registry" |
13 | 12 |
|
14 |
| - stage 'test' |
15 |
| - sh "mvn test" |
| 13 | + stage 'build docker env' |
| 14 | + sh "make build-docker-env" |
16 | 15 |
|
17 |
| - stage 'package' |
18 |
| - sh "mvn package" |
| 16 | + stage 'test project' |
| 17 | + sh "docker-compose run --rm test" |
19 | 18 |
|
20 |
| - stage 'preview' |
21 |
| - sh 'make deploy-default' |
| 19 | + stage 'server project' |
| 20 | + sh "docker-compose up -d server" |
22 | 21 |
|
23 |
| - stage 'report' |
24 |
| - step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*.xml']) |
| 22 | + try{ |
| 23 | + stage 'Approve, go production' |
| 24 | + def url = 'http://localhost:8000/' |
| 25 | + input message: "Does staging at $url look good? ", ok: "Deploy to production" |
| 26 | + }finally{ |
| 27 | + sh "docker-compose stop server" |
| 28 | + } |
25 | 29 |
|
26 |
| - stage 'Artifact' |
27 |
| - step([$class: 'ArtifactArchiver', artifacts: '**/target/*.jar', fingerprint: true]) |
| 30 | + stage 'package project' |
| 31 | + sh "docker-compose run --rm package" |
28 | 32 |
|
29 |
| - try{ |
30 |
| - stage 'Approve, go production' |
31 |
| - def url = 'http://localhost:8000/' |
32 |
| - input message: "Does staging at $url look good? ", ok: "Deploy to production" |
33 |
| - }finally{ |
34 |
| - sh "ssh jenkins@localhost 'kill `cat deploy/release/run.pid`'" |
35 |
| - } |
| 33 | + stage 'build docker production image' |
| 34 | + sh "make build-docker-prod-image" |
36 | 35 |
|
37 |
| - stage 'deploy' |
38 |
| - sh 'make deploy-default' |
| 36 | + stage 'publish docker production image' |
| 37 | + sh "docker push localhost:5000/java_sample_prod" |
| 38 | + |
| 39 | + stage 'deploy production' |
| 40 | + sh "make deploy-production" |
39 | 41 |
|
40 |
| - // slackSend channel: '#integration', color: 'good', message: "success ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)", teamDomain: 'agileworks-tw', token: 'JhXFKEl6cBFoQ4v52BEJw9Mr' |
41 |
| - }catch(e){ |
42 |
| - // slackSend channel: '#integration', color: 'danger', message: "fail ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)", teamDomain: 'agileworks-tw', token: 'JhXFKEl6cBFoQ4v52BEJw9Mr' |
43 |
| - throw e; |
44 |
| - } |
45 | 42 | }
|
0 commit comments