-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
107 lines (90 loc) · 2.25 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
102
103
104
105
106
107
#!groovy
def buildTestAndPackageApp() {
echo ">>> Building, testing and packaging App"
try {
sh "mvn clean verify"
} finally {
junit([healthScaleFactor: 0.0, testResults: '**/target/surefire-reports/*.xml,**/target/failsafe-reports/*.xml'])
}
}
def runJcStressTest() {
try {
sh "./jcstress-test/jcstress.sh"
} finally {
publishHTML (target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'jcstress-test/results',
reportFiles: 'index.html',
reportName: "jcstress Report"
])
}
}
def buildDockerImage() {
echo ">>> Building Docker image"
sh "docker build -t app-image ./app-server"
}
def stopDockerContainerIfRunning() {
echo ">>> Stopping Docker container if running"
sh "docker rm -f \$(docker ps -q --filter 'name=app-container') || true > /dev/null"
}
def startDockerContainer() {
echo ">>> Starting Docker container"
sh "docker run --rm -d --name app-container -p 8090:8090 app-image"
waitForAppToBeUp()
}
def waitForAppToBeUp() {
echo ">>> Waiting for App to be UP"
timeout(time: 30, unit: 'SECONDS') {
waitUntil {
script {
def r = sh script: 'wget -q http://localhost:8090/health -O /dev/null', returnStatus: true
return (r == 0);
}
}
}
}
def runComponentTest() {
echo ">>> Running Component test"
try {
sh "mvn -f=component-test/pom.xml verify -PcompTest"
} finally {
junit([healthScaleFactor: 0.0, testResults: '**/target/surefire-reports/*.xml'])
}
}
def runTaurusTest() {
try {
sh "./performance-test/taurus.sh"
} finally {
perfReport 'performance-test/target/taurus-kpi-report.xml'
}
}
node("local-agent") {
deleteDir()
stage('Checkout') {
git 'http://root@localhost:30080/root/java-ci-example.git'
}
stage('Build & Test') {
buildTestAndPackageApp()
}
stage('Concurrency Stress Test') {
runJcStressTest()
}
stage('Build Docker image') {
buildDockerImage()
}
stage('Start Docker container') {
stopDockerContainerIfRunning()
startDockerContainer()
}
stage('Component Test') {
runComponentTest()
}
stage('Performance Benchmark Test') {
runTaurusTest()
}
stage('Tear down'){
stopDockerContainerIfRunning()
}
}