-
Notifications
You must be signed in to change notification settings - Fork 26
/
Jenkinsfile.qa
164 lines (147 loc) · 4.79 KB
/
Jenkinsfile.qa
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
//Jenkinsfile (Declarative Pipeline)
skip = true
STAGENAME = "qa"
stage('prepare build environment') {
//check ENV
node() {
if ("${NEXUS_HOST}" == '') {
errors "No Nexus Repository defined! check environment variable 'NEXUS_HOST'"
}
printf("-------------- Using NEXUS_HOST=${NEXUS_HOST}")
}
}
stage('deploy QA system') {
node('') {
selectStage(STAGENAME)
checkout scm
parallel activemq: {
ocBakeryDeploy("activemq")
}, web: {
ocBakeryDeploy('bakery-web-server')
}, report: {
ocBakeryDeploy('bakery-report-server')
}, workers: {
ocBakeryDeploy('bakery-workers')
}
}
}
stage('citrus integration tests') {
timeout(time: 2, unit: 'DAYS') {
input message: '==> start citrus integration tests?'
}
node('') {
selectStage(STAGENAME)
stage('deploy wait-server') {
sh "STAGE=${STAGENAME} openshift/helper/create_wait-server.sh"
}
stage('run citrus tests') {
ocCitrusJenkinsSlave()
}
//use default maven node (old-solution)
//stage('run citrus tests') {
// ocCitrusTests("citrus-tests")
//}
}
}
stage('sakuli E2E tests') {
timeout(time: 2, unit: 'DAYS') {
input message: '==> start sakuli E2E tests?'
}
node('') {
selectStage(STAGENAME)
//build and start sakuli tests
ocSakuliBuild('sakuli-test')
parallel blueberry: {
ocRunSakuliTest('blueberry')
}, orderpdf: {
ocRunSakuliTest('order-pdf')
}, chocolate: {
ocRunSakuliTest('chocolate')
}, caramel: {
ocRunSakuliTest('caramel')
}
}
}
stage('Trigger PROD') {
timeout(time: 2, unit: 'DAYS') {
input message: '==> deploy PROD system?'
}
node('') {
ocstage(STAGENAME, "prod")
//use dev jenkins
selectStage("dev")
//delete qa staqe
sh "openshift/delete-deployment-pipeline.sh qa"
//trigger next build pipeline
sh "openshift/create-build-pipeline.sh prod"
}
}
private void selectStage(String stagename) {
sh "oc project ta-pipeline-${stagename}"
}
private void ocBakeryDeploy(String component) {
stage("deploy ${component}") {
try {
sh "openshift/bakery-app/create_${component}.sh delete"
sh "echo 'wait 10 sec. ...' && sleep 10"
} catch (e) {
printf("only housekeeping, do nonting: %s", e.toString())
}
sh "openshift/bakery-app/create_${component}.sh"
}
}
/**
* Custom wrapper for executing the commands in a citrus-slave-image:
* See: https://github.com/citrusframework/citrus-docker-images/pull/3
*
*/
private void ocCitrusJenkinsSlave() {
podTemplate(label: "citrus",
cloud: "openshift",
inheritFrom: "maven",
containers: [
containerTemplate(name: "jnlp",
image: "toschneck/citrus-jenkins-slave",
)
])
{
node('citrus') {
sh "echo execute oc citrus build"
checkout scm
sh "citrus-tests/maven-build.sh ${NEXUS_HOST}"
junit 'citrus-tests/target/citrus-reports/**/*.xml'
archiveArtifacts "citrus-tests/target/citrus-*/**/*"
}
}
}
private void ocCitrusTests(String component) {
node('maven') {
sh "echo execute oc citrus build"
checkout scm
sh "citrus-tests/maven-build.sh ${NEXUS_HOST}"
}
}
private void ocSakuliBuild(String component) {
stage("build ${component} image") {
sh "STAGE=${STAGENAME} openshift/sakuli-tests/create_${component}.sh build"
}
}
private void ocRunSakuliTest(String component) {
stage("start ${component}") {
def statusCode = sh script: "STAGE=${STAGENAME} openshift/sakuli-tests/create_sakuli-test.sh ${component}", returnStatus: true
printf("Sakuli finished with error code: $statusCode")
if (statusCode == 0) {
echo "Sakuli E2E test $component was sucessful!"
} else if (statusCode > 0 && statusCode < 6) {
printf("Sakuli has exceeded warning/critical times in test $component (build marked UNSTABLE)")
currentBuild.result = 'UNSTABLE'
} else {
error "Sakuli have found some errors in test $component!"
}
}
}
private void ocstage(String src, String dest) {
sh "openshift/bakery-app/stage-images.sh ${src} ${dest} bakery-report-server:latest"
sh "openshift/bakery-app/stage-images.sh ${src} ${dest} bakery-web-server:latest"
sh "openshift/bakery-app/stage-images.sh ${src} ${dest} bakery-worker:latest"
}