forked from CMYanko/struts2-rce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebgoat-pipeline.groovy
116 lines (115 loc) · 4.64 KB
/
webgoat-pipeline.groovy
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
def pom
pipeline
{
agent any
tools {
maven 'maven'
jdk 'jdk8'
}
stages {
stage('Checkout') {
steps {
git url: 'https://github.com/Iletee/webgoat-test.git'
}
}
stage('Maven Build') {
steps {
sh '''
cd webgoat
mvn versions:set -DnewVersion=1.0
mvn clean install
sleep 3
'''
}
}
stage('Read Pom') {
steps {
script {
pom = readMavenPom file: 'webgoat/pom.xml'
}
}
}
stage('Publish Artifact and Tag Creation') {
parallel {
stage('Publish Snapshot to Release') {
steps {
nexusPublisher nexusInstanceId: 'nxrm3', \
nexusRepositoryId: 'maven-releases', \
packages: [[$class: 'MavenPackage', \
mavenAssetList: [[classifier: '', extension: '', filePath: "webgoat/target/${pom.artifactId}-${pom.version}.${pom.packaging}"]], \
mavenCoordinate: [artifactId: "${pom.artifactId}", groupId: "${pom.groupId}", packaging: "${pom.packaging}", version: "${pom.version}.${env.BUILD_NUMBER}"]]]
}
}
stage('Create Tags') {
steps {
script {
try {
createTag nexusInstanceId: 'nxrm3', tagName: 'passed-dev-scan'
createTag nexusInstanceId: 'nxrm3', tagName: 'passed-test-scan'
createTag nexusInstanceId: 'nxrm3', tagName: 'passed-prod-scan'
}
catch (Exception e) { //com.sonatype.nexus.api.exception.RepositoryManagerException e) {
echo e.toString()
}
}
}
}
}
}
stage('Scanning, Staging, and Tagging') {
parallel {
stage('Dev') {
stages {
stage('IQ Scan Dev') {
steps {
nexusPolicyEvaluation(iqApplication: 'webgoat', iqStage: 'build')
}
}
stage('Associate Dev Tag') {
steps {
associateTag nexusInstanceId: 'nxrm3', tagName: 'passed-dev-scan', \
search: [[key: 'repository', value: 'maven-releases'], [key: 'version', value: "${pom.version}.${env.BUILD_NUMBER}"]]
}
}
}
}
stage('Test') {
stages {
stage('IQ Scan Test') {
steps {
nexusPolicyEvaluation(iqApplication: 'webgoat', iqStage: 'stage-release')
}
}
stage('Associate Test Tag') {
steps {
associateTag nexusInstanceId: 'nxrm3', tagName: 'passed-test-scan', \
search: [[key: 'repository', value: 'maven-releases'], [key: 'version', value: "${pom.version}.${env.BUILD_NUMBER}"]]
}
}
}
}
stage('Prod') {
stages {
stage('IQ Scan Prod') {
steps {
nexusPolicyEvaluation(iqApplication: 'webgoat', iqStage: 'release')
}
}
stage('Associate Prod Tag') {
steps {
associateTag nexusInstanceId: 'nxrm3', tagName: 'passed-prod-scan', \
search: [[key: 'repository', value: 'maven-releases'], [key: 'version', value: "${pom.version}.${env.BUILD_NUMBER}"]]
}
}
}
}
}
}
}
post ('Promotion') {
always {
moveComponents destination: 'maven-dev', nexusInstanceId: 'nxrm3', tagName: 'passed-dev-scan', repositoryName: 'maven-releases'
echo 'Successfully promoted component'
}
}
}