forked from bcgov/jag-lcrb-carla-public
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDEV-portal-Jenkinsfile
101 lines (91 loc) · 3.75 KB
/
DEV-portal-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
// The builds.
node('master') {
stage('Startup') {
if (changeset("cllc-public-app/ClientApp/*")) {
sh 'oc cancel-build bc/cllc-public-angular'
}
if (changeset("cllc-public-app/*")) {
sh 'oc cancel-build bc/cllc-public-api'
}
}
stage('Build') {
parallel('Angular': {
if (changeset("cllc-public-app/ClientApp/*")) {
openshiftBuild bldCfg: 'cllc-public-angular-build', showBuildLogs: 'true'
}
}, 'C# API': {
if (changeset("cllc-public-app/*")) {
openshiftBuild bldCfg: 'cllc-public-api', showBuildLogs: 'true'
}
})
echo "Building Application image..."
openshiftBuild bldCfg: 'cllc-public-frontend', showBuildLogs: 'true'
openshiftTag destStream: 'cllc-public-frontend', verbose: 'true', destTag: 'dev', srcStream: 'cllc-public-frontend', srcTag: 'latest'
}
}
// ZAP security scan
podTemplate(label: 'owasp-zap2', name: 'owasp-zap2', 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: '/home/jenkins',
command: '',
args: '${computer.jnlpmac} ${computer.name}'
)
]) {
stage('ZAP Security Scan') {
node('owasp-zap2') {
//the checkout is mandatory
echo "checking out source"
echo "Build: ${BUILD_ID}"
checkout scm
dir('/zap') {
def retVal = sh returnStatus: true, script: '/zap/zap-baseline.py -r baseline.html -t http://cannabis-licensing-dev.pathfinder.bcgov'
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}"
}
}
}
}
stage('Automated Tests and code analysis') {
parallel('SonarQube Scan': {
node('master') {
echo "Running SonarQube static code analysis..."
sh 'oc cancel-build bc/cllc-public-sonar'
openshiftBuild bldCfg: 'cllc-public-sonar', showBuildLogs: 'true'
}
}, 'Angular': {
node('nodejs')
{
//the checkout is mandatory, otherwise functional test would fail
echo "checking out source"
echo "Build: ${BUILD_ID}"
checkout scm
dir('cllc-public-app/ClientApp') {
try {
// sh 'Xvfb :1 -screen 0 1024x768x24 &'
// sh 'export DISPLAY=:1'
sh 'npm install -g @angular/cli'
sh 'npm install'
sh 'npm run test-headless'
} finally {
archiveArtifacts allowEmptyArchive: true, artifacts: '*.xml'
junit 'junit.xml'
publishHTML(target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: '.',
reportFiles: 'unit-tests.html',
reportName: "Unit Test Report"
])
}
}
}
}
)
}