forked from michaelmworthington/WebGoat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
102 lines (87 loc) · 2.84 KB
/
Jenkinsfile
File metadata and controls
102 lines (87 loc) · 2.84 KB
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
pipeline {
agent any
stages {
stage('Build') {
steps {
echo "Running ${env.BUILD_ID} on ${env.JENKINS_URL}"
//input 'Build with maven?'
sh '''
env
echo "PATH = ${PATH}"
echo "M2_HOME = ${M2_HOME}"
echo "Build Number = ${BUILD_ID}"
mvn -B clean install -Dmaven.test.skip=true -U
'''
//input 'Continue?'
}
}
stage('Scan App - Build Container') {
parallel {
stage('IQ-BOM') {
steps {
//input 'Scan with IQ at Build?'
nexusPolicyEvaluation(iqApplication: 'WebGoat', iqStage: 'build', iqScanPatterns: [[scanPattern: '']])
}
}
stage('Static Analysis') {
steps {
echo '...run SonarQube or other SAST tools here'
}
}
stage('Build Container') {
steps {
//input 'Build with docker?'
sh '''cd webgoat-server
/usr/local/bin/docker build -t webgoat/webgoat-8.0-${BUILD_ID} .
'''
}
}
}
}
stage('Test Container') {
parallel {
stage('Test Container') {
steps {
catchError() {
echo 'Test Container here'
}
}
}
stage('IQ-Scan Container') {
steps {
//input 'Scan with IQ at Stage-Release?'
sh '/usr/local/bin/docker save webgoat/webgoat-8.0-${BUILD_ID} -o $WORKSPACE/webgoat.tar'
nexusPolicyEvaluation(iqStage: 'stage-release', iqApplication: 'WebGoat')
}
}
}
}
stage('Publish Container') {
when {
branch 'develop'
}
steps {
//input 'Push to Nexus Repo?'
sh '''
/usr/local/bin/docker tag webgoat/webgoat-8.0-${BUILD_ID} localhost:18443/webgoat/webgoat-8.0-${BUILD_ID}:8.0-${BUILD_ID}
/usr/local/bin/docker push localhost:18443/webgoat/webgoat-8.0-${BUILD_ID}
'''
}
}
stage('Create Tag') {
when {
branch 'develop'
}
steps {
//input 'Create tag in Nexus Repo?'
createTag nexusInstanceId: 'nexus', tagName: "DockerStagingDemoJenkinsfile-Webgoat8-${env.BUILD_ID}"
associateTag nexusInstanceId: 'nexus', search: [[key: 'repository', value: 'docker-hosted-beta'], [key: 'name', value: "webgoat/webgoat-8.0-${env.BUILD_ID}"], [key: 'version', value: "8.0-${env.BUILD_ID}"]], tagName: "DockerStagingDemoJenkinsfile-Webgoat8-${env.BUILD_ID}"
input 'Move Image out of Beta?'
moveComponents destination: 'docker-hosted', nexusInstanceId: 'nexus', tagName: "DockerStagingDemoJenkinsfile-Webgoat8-${env.BUILD_ID}"
}
}
}
tools {
maven 'localmaven'
}
}