forked from bcgov/gcpe-news-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile-develop-full
109 lines (100 loc) · 3.93 KB
/
Jenkinsfile-develop-full
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
node('master') {
stage('Code Quality') {
echo "Running SonarQube static code analysis."
openshiftBuild bldCfg: 'news-webapp-sonar-develop', showBuildLogs: 'true'
}
stage('Dependency Security Check') {
echo "Running Snyk analysis of dependencies"
openshiftBuild bldCfg: 'news-webapp-snyk-develop', showBuildLogs: 'true'
}
stage('Build Image') {
echo "Building..."
openshiftBuild bldCfg: 'news-webapp-develop', showBuildLogs: 'true'
openshiftTag destStream: 'news-webapp', verbose: 'true', destTag: '$BUILD_ID', srcStream: 'news-webapp', srcTag: 'latest'
}
stage('Deploy on Dev') {
echo "Deploying to dev..."
openshiftTag destStream: 'news-webapp', verbose: 'true', destTag: 'dev', srcStream: 'news-webapp', srcTag: '$BUILD_ID'
//Sleeping for a while to wait deployment completes
sh 'sleep 1m'
}
}
//See https://github.com/jenkinsci/kubernetes-plugin
podTemplate(label: 'owasp-zap', name: 'owasp-zap', serviceAccount: 'jenkins', cloud: 'openshift', containers: [
containerTemplate(
name: 'jnlp',
image: '172.50.0.2:5000/openshift/jenkins-slave-zap',
resourceRequestCpu: '500m',
resourceLimitCpu: '1000m',
resourceRequestMemory: '3Gi',
resourceLimitMemory: '4Gi',
workingDir: '/tmp',
command: '',
args: '${computer.jnlpmac} ${computer.name}'
)
]) {
node('owasp-zap') {
stage('ZAP Security Scan') {
dir('/zap') {
def retVal = sh returnStatus: true, script: '/zap/zap-baseline.py -r baseline.html -t https://dev.news.gov.bc.ca'
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: '/zap/wrk', reportFiles: 'baseline.html', reportName: 'ZAP Baseline Scan', reportTitles: 'ZAP Baseline Scan'])
echo "Return value is: ${retVal}"
}
}
}
}
//See https://github.com/jenkinsci/kubernetes-plugin
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}'
)
]) {
node('bddstack') {
stage('FT on Dev') {
//the checkout is mandatory, otherwise functional test would fail
echo "checking out source"
echo "Build: ${BUILD_ID}"
checkout scm
dir('functional-tests') {
try {
sh './gradlew --debug --stacktrace chromeHeadlessTest'
} finally {
archiveArtifacts allowEmptyArchive: true, artifacts: 'build/reports/**/*'
archiveArtifacts allowEmptyArchive: true, artifacts: 'build/test-results/**/*'
junit 'build/test-results/**/*.xml'
publishHTML (target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'build/reports/spock',
reportFiles: 'index.html',
reportName: "BDD Spock Report"
])
publishHTML (target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'build/reports/tests/chromeHeadlessTest',
reportFiles: 'index.html',
reportName: "Full Test Report"
])
}
}
}
}
}
stage('Deploy on Test') {
input "Deploy to test?"
node('master') {
openshiftTag destStream: 'news-webapp', verbose: 'true', destTag: 'test', srcStream: 'news-webapp', srcTag: '$BUILD_ID'
sh 'sleep 3m'
}
}