forked from bcgov/gwells
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
182 lines (177 loc) · 8.37 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
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
node('maven') {
stage('Build') {
echo "Building..."
openshiftBuild bldCfg: 'gwells', showBuildLogs: 'true', waitTime: 1800000
openshiftTag destStream: 'gwells', verbose: 'true', destTag: '$BUILD_ID', srcStream: 'gwells', srcTag: 'latest'
}
podTemplate(label: 'pythonnodejs', name: 'pythonnodejs', serviceAccount: 'jenkins', cloud: 'openshift', containers: [
containerTemplate(
name: 'jnlp',
image: '172.50.0.2:5000/openshift/jenkins-slave-python3nodejs',
resourceRequestCpu: '500m',
resourceLimitCpu: '1000m',
resourceRequestMemory: '1Gi',
resourceLimitMemory: '4Gi',
workingDir: '/tmp',
command: '',
args: '${computer.jnlpmac} ${computer.name}'
)
])
{
stage('Unit Test') {
node('pythonnodejs') {
checkout scm
try {
sh 'pip install --upgrade pip && pip install -r requirements.txt'
sh 'cd frontend && npm install && npm run build && cd ..'
sh 'python manage.py collectstatic && python manage.py migrate'
sh 'export ENABLE_DATA_ENTRY="True" && python manage.py test -c nose.cfg'
sh 'cd frontend && npm test && cd ..'
}
finally {
archiveArtifacts allowEmptyArchive: true, artifacts: 'frontend/test/unit/**/*'
stash includes: 'nosetests.xml,coverage.xml', name: 'coverage'
stash includes: 'frontend/test/unit/coverage/clover.xml', name: 'nodecoverage'
stash includes: 'frontend/junit.xml', name: 'nodejunit'
junit 'nosetests.xml,frontend/junit.xml'
publishHTML (target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'frontend/test/unit/coverage/lcov-report/',
reportFiles: 'index.html',
reportName: "Node Coverage Report"
])
}
}
}
}
stage('Deploy on Test') {
echo "Deploying to Test..."
openshiftTag destStream: 'gwells', verbose: 'true', destTag: 'test', srcStream: 'gwells', srcTag: '$BUILD_ID'
//sleep 5
//openshiftVerifyDeployment depCfg: 'gwells', namespace: 'moe-gwells-test', replicaCount: 1, verbose: 'false', verifyReplicaCount: 'false', waitTime: 600000
echo ">>>> Test Deployment Complete"
}
}
podTemplate(label: 'bddstack', name: 'bddstack', serviceAccount: 'jenkins', cloud: 'openshift', containers: [
containerTemplate(
name: 'jnlp',
image: '172.50.0.2:5000/openshift/jenkins-slave-bddstack',
resourceRequestCpu: '500m',
resourceLimitCpu: '1000m',
resourceRequestMemory: '1Gi',
resourceLimitMemory: '4Gi',
workingDir: '/home/jenkins',
command: '',
args: '${computer.jnlpmac} ${computer.name}',
envVars: [
envVar(key:'BASEURL', value: 'https://testapps.nrs.gov.bc.ca/')
]
)
])
{
stage('Smoke Test on Test') {
input "Ready to start Tests?"
node('bddstack') {
//the checkout is mandatory, otherwise functional test would fail
echo "checking out source"
echo "Build: ${BUILD_ID}"
checkout scm
dir('functional-tests/build/test-results') {
unstash 'coverage'
sh 'rm coverage.xml'
unstash 'nodejunit'
}
dir('functional-tests') {
try {
sh './gradlew -DchromeHeadlessTest.single=WellDetails chromeHeadlessTest'
} finally {
archiveArtifacts allowEmptyArchive: true, artifacts: 'build/reports/geb/**/*'
junit 'build/test-results/**/*.xml'
publishHTML (target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'build/reports/spock',
reportFiles: 'index.html',
reportName: "Test: BDD Spock Report"
])
publishHTML (target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'build/reports/tests/chromeHeadlessTest',
reportFiles: 'index.html',
reportName: "Test: Full Test Report"
])
perfReport compareBuildPrevious: true, excludeResponseTime: true, ignoreFailedBuilds: true, ignoreUnstableBuilds: true, modeEvaluation: true, modePerformancePerTestCase: true, percentiles: '0,50,90,100', relativeFailedThresholdNegative: 80.0, relativeFailedThresholdPositive: 20.0, relativeUnstableThresholdNegative: 50.0, relativeUnstableThresholdPositive: 50.0, sourceDataFiles: 'build/test-results/**/*.xml'
}
}
}
}
}
stage('Deploy on Prod') {
input "Deploy to Prod?"
node('maven') {
openshiftTag destStream: 'gwells', verbose: 'true', destTag: 'prod', srcStream: 'gwells', srcTag: '$BUILD_ID'
sh 'sleep 3m'
}
}
podTemplate(label: 'bddstack', name: 'bddstack', serviceAccount: 'jenkins', cloud: 'openshift', containers: [
containerTemplate(
name: 'jnlp',
image: '172.50.0.2:5000/openshift/jenkins-slave-bddstack',
resourceRequestCpu: '500m',
resourceLimitCpu: '1000m',
resourceRequestMemory: '1Gi',
resourceLimitMemory: '4Gi',
workingDir: '/home/jenkins',
command: '',
args: '${computer.jnlpmac} ${computer.name}',
envVars: [
envVar(key:'BASEURL', value: 'https://apps.nrs.gov.bc.ca/')
]
)
])
{
stage('Smoke Test on Prod') {
input "Ready to smoke test Prod?"
node('bddstack') {
//the checkout is mandatory, otherwise functional test would fail
echo "checking out source"
echo "Build: ${BUILD_ID}"
checkout scm
dir('functional-tests/build/test-results') {
unstash 'coverage'
sh 'rm coverage.xml'
unstash 'nodejunit'
}
dir('functional-tests') {
try {
sh './gradlew -DchromeHeadlessTest.single=WellDetails chromeHeadlessTest'
} finally {
archiveArtifacts allowEmptyArchive: true, artifacts: 'build/reports/geb/**/*'
junit 'build/test-results/**/*.xml'
publishHTML (target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'build/reports/spock',
reportFiles: 'index.html',
reportName: "Prod: BDD Spock Report"
])
publishHTML (target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'build/reports/tests/chromeHeadlessTest',
reportFiles: 'index.html',
reportName: "Prod: Full Test Report"
])
perfReport compareBuildPrevious: true, excludeResponseTime: true, ignoreFailedBuilds: true, ignoreUnstableBuilds: true, modeEvaluation: true, modePerformancePerTestCase: true, percentiles: '0,50,90,100', relativeFailedThresholdNegative: 80.0, relativeFailedThresholdPositive: 20.0, relativeUnstableThresholdNegative: 50.0, relativeUnstableThresholdPositive: 50.0, sourceDataFiles: 'build/test-results/**/*.xml'
}
}
}
}
}