6
6
import groovy.json.JsonSlurperClassic
7
7
8
8
9
+
9
10
gitCredID = ' marklogic-builder-github'
10
11
JIRA_ID = ' '
11
12
JIRA_ID_PATTERN = / (?i)(MLE)-\d {3,6}/
@@ -104,7 +105,7 @@ void resultNotification(message) {
104
105
emailList = params. emailList
105
106
}
106
107
jira_link = " https://project.marklogic.com/jira/browse/${ JIRA_ID} "
107
- email_body = " <b>Jenkins pipeline for</b> ${ env.JOB_NAME} <br><b>Build Number: </b>${ env.BUILD_NUMBER} <b ><br><br >Lint Output: <br></b>< pre><code>${ LINT_OUTPUT } </code></pre><br><br><b>Build URL: </b><br>${ env.BUILD_URL} "
108
+ email_body = " <b>Jenkins pipeline for</b> ${ env.JOB_NAME} <br><b>Build Number: </b>${ env.BUILD_NUMBER} <br ><br><b >Lint Output: </b>< br><pre><code> ${ LINT_OUTPUT } </code></pre><br><br><b>Scan Output: </b><br>< pre><code>${ SCAN_OUTPUT } </code></pre><br><br><b>Build URL: </b><br>${ env.BUILD_URL} "
108
109
jira_email_body = " ${ email_body} <br><br><b>Jira URL: </b><br>${ jira_link} "
109
110
110
111
if (JIRA_ID ) {
@@ -128,6 +129,18 @@ void lint() {
128
129
'''
129
130
}
130
131
132
+ void imageScan () {
133
+ sh " make image-scan saveOutput=true"
134
+
135
+ SCAN_OUTPUT = sh(returnStdout : true , script :' cat dep-image-scan.txt' )
136
+ hasCriticalOrHigh = SCAN_OUTPUT . contains(" High" ) || SCAN_OUTPUT . contains(" Critical" )
137
+ if (hasCriticalOrHigh) {
138
+ mail charset : ' UTF-8' , mimeType : ' text/html' , to : " ${ emailSecList} " , body : " <br>Jenkins pipeline for ${ env.JOB_NAME} <br>Build Number: ${ env.BUILD_NUMBER} <br>Vulnerabilities: <pre><code>${ SCAN_OUTPUT} </code></pre>" , subject : " Critical or High Security Vulnerabilities Found: ${ env.JOB_NAME} #${ env.BUILD_NUMBER} "
139
+ }
140
+
141
+ sh ''' rm -f dep-image-scan.txt'''
142
+ }
143
+
131
144
void publishTestResults () {
132
145
junit allowEmptyResults :true , testResults : ' **/test/test_results/*.xml'
133
146
archiveArtifacts artifacts : ' **/test/test_results/*.xml' , allowEmptyArchive : true
@@ -156,7 +169,7 @@ pipeline {
156
169
skipStagesAfterUnstable()
157
170
}
158
171
triggers {
159
- parameterizedCron( env. BRANCH_NAME == ' develop' ? ''' 00 04 * * *''' : ' ' )
172
+ parameterizedCron( env. BRANCH_NAME == ' develop' ? ''' 00 04 * * * % IMAGE_SCAN=true ''' : ' ' )
160
173
}
161
174
environment {
162
175
// timeStamp = sh(returnStdout: true, script: "date +%Y%m%d -d '-5 hours'").trim()
@@ -174,6 +187,7 @@ pipeline {
174
187
choice(name : ' ML_VERSION' , choices : ' 11.2\n 12.0\n 10.0' , description : ' MarkLogic version. used to pick appropriate docker image' )
175
188
booleanParam(name : ' KUBERNETES_TESTS' , defaultValue : true , description : ' Run kubernetes tests' )
176
189
booleanParam(name : ' HC_TESTS' , defaultValue : false , description : ' Run Hub Central E2E UI tests (takes about 3 hours)' )
190
+ booleanParam(name : ' IMAGE_SCAN' , defaultValue : false , description : ' Find and scan dependent Docker images for security vulnerabilities' )
177
191
string(name : ' dockerReleaseVer' , defaultValue : ' 1.1.2' , description : ' Current Docker version. (e.g. 1.0.1)' , trim : true )
178
192
choice(name : ' PREV_ML_VERSION' , choices : ' 10.0\n 9.0\n 11.2' , description : ' Previous MarkLogic version for MarkLogic upgrade tests' )
179
193
string(name : ' prevDockerReleaseVer' , defaultValue : ' 1.1.2' , description : ' Previous Docker version for MarkLogic upgrade tests. (e.g. 1.0.1)' , trim : true )
@@ -193,6 +207,15 @@ pipeline {
193
207
}
194
208
}
195
209
210
+ stage(' Image-Scan' ) {
211
+ when {
212
+ expression { return params. IMAGE_SCAN }
213
+ }
214
+ steps {
215
+ imageScan()
216
+ }
217
+ }
218
+
196
219
stage(' Kubernetes-Run-Tests' ) {
197
220
when {
198
221
expression { return params. KUBERNETES_TESTS }
0 commit comments