Skip to content

Commit cba408f

Browse files
author
Vitaly Korolev
committed
Update to handle new haproxy image location
1 parent 4fb34e7 commit cba408f

File tree

2 files changed

+25
-19
lines changed

2 files changed

+25
-19
lines changed

Jenkinsfile

Lines changed: 15 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,10 @@ void imageScan() {
147147
}
148148

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

152156
void publishTestResults() {
@@ -261,13 +265,16 @@ pipeline {
261265
sh "rm -rf $WORKSPACE/test/test_results/"
262266
}
263267
success {
264-
resultNotification('BUILD SUCCESS ✅')
268+
resultNotification('✅ Success')
265269
}
266270
failure {
267-
resultNotification('BUILD ERROR ❌')
271+
resultNotification('❌ Failure')
268272
}
269273
unstable {
270-
resultNotification('BUILD UNSTABLE ❌')
274+
resultNotification('⚠️ Unstable')
275+
}
276+
aborted {
277+
resultNotification('🚫 Aborted')
271278
}
272279
}
273280
}

makefile

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,11 @@ upgrade-test: prepare
232232
## * [saveOutput] optional. Save the output to a text file. Example: saveOutput=true
233233
.PHONY: image-scan
234234
image-scan:
235+
@rm -f helm_image.list dep-image-scan.txt
235236
@$(if $(saveOutput), > dep-image-scan.txt)
236-
@echo "=====Scan dependent Docker images in charts/values.yaml and charts/charts/haproxy/values.yaml" $(if $(saveOutput), | tee -a dep-image-scan.txt,)
237+
@echo "=====Scan dependent Docker images in charts/values.yaml" $(if $(saveOutput), | tee -a dep-image-scan.txt,)
237238
set -e; \
238239
scanned_images_tracker_file="$$(mktemp)"; \
239-
trap 'rm -f "$$scanned_images_tracker_file"' EXIT; \
240240
scan_image() { \
241241
img="$$1"; \
242242
src_file="$$2"; \
@@ -275,7 +275,7 @@ image-scan:
275275
else \
276276
scan_out_body=$$(echo "$$grype_json_output" | jq -r 'def sevorder: {Critical:0, High:1, Medium:2, Low:3, Negligible:4, Unknown:5}; [.matches[]? | {pkg: .artifact.name, ver: .artifact.version, cve: .vulnerability.id, sev: .vulnerability.severity}] | map(. + {sort_key: sevorder[.sev // "Unknown"]}) | sort_by(.sort_key) | .[] | [.pkg // "N/A", .ver // "N/A", .cve // "N/A", .sev // "N/A"] | @tsv'); \
277277
if [ -n "$$scan_out_body" ]; then \
278-
(echo -e "Package\tVersion\tCVE\tSeverity"; echo "$$scan_out_body") | column -t -s $$'\t' $(if $(saveOutput), | tee -a dep-image-scan.txt,); \
278+
(echo "Package\tVersion\tCVE\tSeverity"; echo "$$scan_out_body") | column -t -s $$'\t' $(if $(saveOutput), | tee -a dep-image-scan.txt,); \
279279
else \
280280
echo "No vulnerability details to display for $$img (though summary reported counts)." $(if $(saveOutput), | tee -a dep-image-scan.txt,); \
281281
fi; \
@@ -284,11 +284,10 @@ image-scan:
284284
}; \
285285
util_image=$$(grep -A2 'utilContainer:' charts/values.yaml | grep 'image:' | sed 's/.*image:[[:space:]]*//g' | sed 's/"//g' | xargs); \
286286
scan_image "$$util_image" "charts/values.yaml"; \
287-
haproxy_image=$$(grep -A2 'image:' charts/charts/haproxy/values.yaml | grep 'repository:' | sed 's/.*repository:[[:space:]]*//g' | sed 's/"//g' | sed 's/#.*//g' | xargs); \
288-
haproxy_tag=$$(grep -A2 'image:' charts/charts/haproxy/values.yaml | grep 'tag:' | sed 's/.*tag:[[:space:]]*//g' | sed 's/"//g' | sed 's/{{.*}}/latest/' | sed 's/#.*//g' | xargs); \
289-
scan_image "$$haproxy_image:$$haproxy_tag" "charts/charts/haproxy/values.yaml"; \
290-
for extra_image in $$(grep -v '^\s*#' charts/charts/haproxy/values.yaml | grep -E 'image:[[:space:]]*[^[:space:]]+' | grep -v 'repository:' | grep -v 'tag:' | sed 's/.*image:[[:space:]]*//g' | sed 's/"//g' | sed 's/#.*//g' | xargs -n1); do \
291-
if [ -n "$$extra_image" ] && [ "$$extra_image" != "image:" ]; then \
292-
scan_image "$${extra_image}" "charts/charts/haproxy/values.yaml"; \
293-
fi; \
294-
done
287+
haproxy_image=$$(grep -A 3 '^haproxy:' charts/values.yaml | grep -A 1 '^\s*image:' | grep '^\s*repository:' | sed 's/.*repository:[[:space:]]*//g' | sed 's/"//g' | sed 's/#.*//g' | xargs); \
288+
haproxy_tag=$$(grep -A 4 '^haproxy:' charts/values.yaml | grep -A 2 '^\s*image:' | grep '^\s*tag:' | sed 's/.*tag:[[:space:]]*//g' | sed 's/"//g' | sed 's/{{.*}}/latest/' | sed 's/#.*//g' | xargs); \
289+
scan_image "$$haproxy_image:$$haproxy_tag" "charts/values.yaml";
290+
@# Remove trailing comma from helm_image.list if present
291+
@if [ -f helm_image.list ]; then \
292+
sed -i '' -e 's/,\s*$$//' helm_image.list; \
293+
fi

0 commit comments

Comments
 (0)