forked from WebGoat/WebGoat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
89 lines (87 loc) · 2.64 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
pipeline {
agent any
tools {
maven 'M3'
jdk 'jdk8'
}
stages {
stage ('Build') {
steps {
sh '''
echo "PATH = ${PATH}"
echo "M2_HOME = ${M2_HOME}"
mvn -B -DskipTest=true install
'''
}
post {
always {
junit '**/target/surefire-reports/**/*.xml'
}
}
}
stage('Scan App - Build Container') {
steps{
parallel('IQ-BOM': {
nexusPolicyEvaluation failBuildOnNetworkError: false,
iqApplication: 'webgoat8',
iqStage: 'build',
iqScanPatterns: [[scanPattern: '']],
jobCredentialsId: ''
},
'Static Analysis': {
echo '...run SonarQube or other SAST tools here'
},
'Build Container': {
sh '''
cd webgoat-server
mvn -B docker:build
'''
})
}
}
stage('Test Container') {
steps{
echo '...run container and test it'
}
post {
success {
echo '...the Test Scan Passed!'
}
failure {
echo '...the Test FAILED'
error("...the Container Test FAILED")
}
}
}
stage('Scan Container') {
steps{
sh "docker save mycompany.com:18444/webgoat/webgoat-8.0 -o ${env.WORKSPACE}/webgoat.tar"
nexusPolicyEvaluation failBuildOnNetworkError: false,
iqApplication: 'webgoat8',
iqStage: 'release',
iqScanPatterns: [[scanPattern: '*.tar']],
jobCredentialsId: ''
}
post {
success {
echo '...the IQ Scan PASSED :D'
}
failure {
echo '...the IQ Scan FAILED :('
error("...the IQ Scan FAILED")
}
}
}
stage('Publish Container') {
when {
branch 'master'
}
steps {
sh '''
docker tag webgoat/webgoat-8.0 mycompany.com:18444/webgoat/webgoat-8.0:8.0
docker push mycompany.com:18444/webgoat/webgoat-8.0
'''
}
}
}
}