Skip to content

Commit 054c786

Browse files
committed
update
1 parent ba32070 commit 054c786

File tree

5 files changed

+83
-78
lines changed

5 files changed

+83
-78
lines changed

Jenkinsfile

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,42 @@
11
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
82

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'
107

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"
1312

14-
stage 'test'
15-
sh "mvn test"
13+
stage 'build docker env'
14+
sh "make build-docker-env"
1615

17-
stage 'package'
18-
sh "mvn package"
16+
stage 'test project'
17+
sh "docker-compose run --rm test"
1918

20-
stage 'preview'
21-
sh 'make deploy-default'
19+
stage 'server project'
20+
sh "docker-compose up -d server"
2221

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+
}
2529

26-
stage 'Artifact'
27-
step([$class: 'ArtifactArchiver', artifacts: '**/target/*.jar', fingerprint: true])
30+
stage 'package project'
31+
sh "docker-compose run --rm package"
2832

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"
3635

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"
3941

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-
}
4542
}

Jenkinsfile_default

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
9+
stage 'check env'
10+
11+
sh "mvn -v"
12+
sh "java -version"
13+
14+
stage 'test'
15+
sh "mvn test"
16+
17+
stage 'package'
18+
sh "mvn package"
19+
20+
stage 'preview'
21+
sh 'make deploy-default'
22+
23+
stage 'report'
24+
step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*.xml'])
25+
26+
stage 'Artifact'
27+
step([$class: 'ArtifactArchiver', artifacts: '**/target/*.jar', fingerprint: true])
28+
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+
}
36+
37+
stage 'deploy'
38+
sh 'make deploy-default'
39+
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+
}

Jenkinsfile_docker

Lines changed: 0 additions & 41 deletions
This file was deleted.

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
start-docker-registry:
2+
- docker run -d -p 5000:5000 --name registry registry:2
3+
4+
15
build-docker-env:
26
docker build -t localhost:5000/maven dockers/maven
37

docker-compose.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ data:
55
command: "/bin/sh"
66

77
install:
8-
image: agileworks/maven
8+
image: localhost:5000/maven
99
volumes:
1010
- ./:/app
1111
volumes_from:
@@ -14,7 +14,7 @@ install:
1414
command: "mvn install"
1515

1616
test:
17-
image: agileworks/maven
17+
image: localhost:5000/maven
1818
volumes:
1919
- ./:/app
2020
volumes_from:
@@ -23,7 +23,7 @@ test:
2323
command: "mvn test"
2424

2525
server:
26-
image: agileworks/maven
26+
image: localhost:5000/maven
2727
volumes:
2828
- ./:/app
2929
- ~/.m2:/root/.m2
@@ -33,7 +33,7 @@ server:
3333
command: "mvn spring-boot:run"
3434

3535
package:
36-
image: agileworks/maven
36+
image: localhost:5000/maven
3737
volumes:
3838
- ./:/app
3939
- ~/.m2:/root/.m2

0 commit comments

Comments
 (0)