Skip to content

Commit f7ebb69

Browse files
Merge pull request #316 from vitalykorolev/MLE-19837_add-blackduck-scan
MLE-19837 add blackduck scan
2 parents 17d09c9 + 7254949 commit f7ebb69

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

Jenkinsfile

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import groovy.json.JsonSlurperClassic
77

88
9-
9+
emailSecList = '[email protected]'
1010
gitCredID = 'marklogic-builder-github'
1111
JIRA_ID = ''
1212
JIRA_ID_PATTERN = /(?i)(MLE)-\d{3,6}/
@@ -103,7 +103,7 @@ def getReviewState() {
103103
return reviewState
104104
}
105105

106-
void resultNotification(message) {
106+
void resultNotification(status) {
107107
def author, authorEmail, emailList
108108
if (env.CHANGE_AUTHOR) {
109109
author = env.CHANGE_AUTHOR.toString().trim().toLowerCase()
@@ -117,11 +117,11 @@ void resultNotification(message) {
117117
jira_email_body = "${email_body} <br><br><b>Jira URL: </b><br><a href='${jira_link}'>${jira_link}</a>"
118118

119119
if (JIRA_ID) {
120-
def comment = [ body: "Jenkins pipeline build result: ${message}" ]
120+
def comment = [ body: "Jenkins pipeline build result: ${status}" ]
121121
jiraAddComment site: 'JIRA', idOrKey: JIRA_ID, failOnError: false, input: comment
122-
mail charset: 'UTF-8', mimeType: 'text/html', to: "${emailList}", body: "${jira_email_body}", subject: "${message}: ${env.JOB_NAME} #${env.BUILD_NUMBER} - ${JIRA_ID}"
122+
mail charset: 'UTF-8', mimeType: 'text/html', to: "${emailList}", body: "${jira_email_body}", subject: "🥷 ${status}: ${env.JOB_NAME} #${env.BUILD_NUMBER} - ${JIRA_ID}"
123123
} else {
124-
mail charset: 'UTF-8', mimeType: 'text/html', to: "${emailList}", body: "${email_body}", subject: "${message}: ${env.JOB_NAME} #${env.BUILD_NUMBER}"
124+
mail charset: 'UTF-8', mimeType: 'text/html', to: "${emailList}", body: "${email_body}", subject: "🥷 ${status}: ${env.JOB_NAME} #${env.BUILD_NUMBER}"
125125
}
126126
}
127127

@@ -147,6 +147,11 @@ void imageScan() {
147147
}
148148

149149
sh '''rm -f dep-image-scan.txt'''
150+
151+
// trigger BlackDuck scan
152+
def rawImageList = readFile(file: 'helm_image.list').trim()
153+
def imageList = rawImageList.endsWith(',') ? rawImageList[0..-2] : rawImageList
154+
build job: 'securityscans/Blackduck/KubeNinjas/kubernetes-helm', wait: false, parameters: [ string(name: 'branch', value: "${env.BRANCH_NAME}"), string(name: 'CONTAINER_IMAGES', value: "${imageList}") ]
150155
}
151156

152157
void publishTestResults() {
@@ -261,13 +266,16 @@ pipeline {
261266
sh "rm -rf $WORKSPACE/test/test_results/"
262267
}
263268
success {
264-
resultNotification('BUILD SUCCESS ✅')
269+
resultNotification('✅ Success')
265270
}
266271
failure {
267-
resultNotification('BUILD ERROR ❌')
272+
resultNotification('❌ Failure')
268273
}
269274
unstable {
270-
resultNotification('BUILD UNSTABLE ❌')
275+
resultNotification('⚠️ Unstable')
276+
}
277+
aborted {
278+
resultNotification('🚫 Aborted')
271279
}
272280
}
273281
}

makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,10 @@ upgrade-test: prepare
233233
.PHONY: image-scan
234234
image-scan:
235235

236+
@rm -f helm_image.list dep-image-scan.txt
236237
@echo "=====Scan dependent Docker images in charts/values.yaml" $(if $(saveOutput), | tee -a dep-image-scan.txt,)
237238
@for depImage in $(shell grep -E "^\s*\bimage:\s+(.*)" charts/values.yaml | sed 's/image: //g' | sed 's/"//g'); do\
239+
echo -n "$${depImage}," >> helm_image.list ; \
238240
echo "= $${depImage}:" $(if $(saveOutput), | tee -a dep-image-scan.txt,) ; \
239241
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock anchore/grype:latest --output json $${depImage} | jq -r '[(.matches[] | [.artifact.name, .artifact.version, .vulnerability.id, .vulnerability.severity])] | .[] | @tsv' | sort -k4 | column -t $(if $(saveOutput), | tee -a dep-image-scan.txt,);\
240242
echo $(if $(saveOutput), | tee -a dep-image-scan.txt,) ;\

0 commit comments

Comments
 (0)