-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathJenkinsfile
101 lines (86 loc) · 2.18 KB
/
Jenkinsfile
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
stage 'Checkout project'
node {
git url: 'https://github.com/zjx-immersion/api-stack.git'
}
stage 'Check env'
node {
sh "java -version"
sh "docker version"
}
stage 'Build and Unit test'
node {
sh "./gradlew clean build"
dir("build") {
sh "ls -a"
}
junit 'build/test-results/test/TEST-*.xml'
stash excludes: 'src/', includes: '**', name: 'source'
}
stage 'API test'
node {
sh "./gradlew apiTest"
dir("build") {
sh "ls -a"
}
}
stage 'package'
node {
sh "./gradlew bootRepackage"
sh "ls -a"
archive includes: "build/libs/*.jar"
archive includes: "build/*"
}
stage 'Test Report'
node {
unstash 'source'
dir("build") {
sh "ls -a"
}
publishHTML(target: [
allowMissing : false,
alwaysLinkToLastBuild: false,
keepAll : true,
reportDir : 'build/reports/jacoco/html',
reportFiles : 'index.html',
reportName : "RCov Report"
])
}
stage 'Artifact'
node {
step([$class: 'ArtifactArchiver', artifacts: '**/build/libs/*.jar', fingerprint: true])
}
stage 'Approve, go production'
node {
try {
def url = 'http://localhost:90011/info'
input message: "Does staging at $url look good? ", ok: "Deploy to production"
} finally {
sh "echo 'Ready to prepare the ENV and Deployment'"
}
}
stage('docker clear')
node {
script {
sh 'chmod +x ./src/main/docker/clear.sh'
POM_VERSION = sh(script: "./src/main/docker/clear.sh", returnStdout: true)
echo "${POM_VERSION}"
}
sh "./gradlew buildDocker"
}
stage 'Deploy'
node {
sh "echo 'Run API Server in Container'"
sh "docker run --name=api-server -d -p 5000:8082 zhongjx/api-stack "
deleteDir()
}
def archiveUnitTestResults() {
step([$class: "JUnitResultArchiver", testResults: "build/**/TEST-*.xml"])
}
def archiveCheckstyleResults() {
step([$class : "CheckStylePublisher",
canComputeNew : false,
defaultEncoding: "",
healthy : "",
pattern : "build/reports/checkstyle/main.xml",
unHealthy : ""])
}