Skip to content

Commit 24f9a63

Browse files
Merge pull request #319 from marklogic/release_2.1.0
Release 2.1.0
2 parents 6916c9c + 4ca0cba commit 24f9a63

15 files changed

+328
-261
lines changed

Jenkinsfile

+105-35
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import groovy.json.JsonSlurperClassic
77

88
// email list for scheduled builds (includes security vulnerability)
9-
emailList = '[email protected], [email protected], Fayez.Saliba@progress.com, Sumanth.Ravipati@progress.com, Peng.Zhou@progress.com'
9+
emailList = '[email protected], [email protected], Sumanth.Ravipati@progress.com, Peng.Zhou@progress.com, romain.winieski@progress.com'
1010
// email list for security vulnerabilities only
1111
1212
gitCredID = 'marklogic-builder-github'
@@ -104,17 +104,43 @@ void resultNotification(message) {
104104
} else {
105105
emailList = params.emailList
106106
}
107-
jira_link = "https://progresssoftware.atlassian.net/browse/${JIRA_ID}"
108-
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><b>Vulnerabilities: </b><pre><code>${SCAN_OUTPUT}</code></pre> <br><b>Image Size: <br></b>${IMAGE_SIZE} <br><pre><code>docker pull ${dockerRegistry}/${latestTag}</code></pre><br><br><b>Build URL: </b><br><a href='${env.BUILD_URL}'>${env.BUILD_URL}</a>"
109-
jira_email_body = "${email_body} <br><br><b>Jira URL: </b><br><a href='${jira_link}'>${jira_link}</a>"
110-
107+
108+
email_body = "<b>Build URL: </b><a href='${env.BUILD_URL}'>${env.BUILD_URL}</a><br/>" +
109+
"<b>Image type: </b>${env.dockerImageType}<br/><br/>" +
110+
"<b>Lint Output: </b><br/>" +
111+
"<pre><code>${LINT_OUTPUT}</code></pre><br/>" +
112+
"<b>Vulnerabilities: </b><pre><code>${SCAN_OUTPUT}</code></pre><br/>" +
113+
"<b><a href='${env.BUILD_URL}artifact/scan/report-${env.dockerImageType}.json'>Full scan report.</a></b><br/>" +
114+
"<b>Image Size: <br/></b>${IMAGE_SIZE} <br/>" +
115+
"<pre><code>docker pull ${dockerRegistry}/${latestTag}</code></pre><br/><br/>"
116+
if (params.DOCKER_TESTS) {
117+
email_body = "${email_body} <b><a href='${env.BUILD_URL}Docker_20Tests_20Report'>Docker Tests Report</a></b><br/>"
118+
} else {
119+
email_body = "${email_body} <b>Docker Tests Skipped</b><br/>"
120+
}
121+
if (params.SCAP_SCAN) {
122+
email_body = "${email_body} <b><a href='${env.BUILD_URL}Open_20SCAP_20Report'>SCAP Scan Report</a></b><br/>"
123+
if ( BRANCH_NAME == 'develop' ) {
124+
emailList = emailList+','+emailSecList
125+
}
126+
} else {
127+
email_body = "${email_body} <b>SCAP Scan Skipped</b><br/>"
128+
}
129+
130+
// If Jira ID is available, add comment to the ticket and add link to email.
111131
if (JIRA_ID) {
132+
def jira_link = "https://progresssoftware.atlassian.net/browse/${JIRA_ID}"
112133
def comment = [ body: "Jenkins pipeline build result: ${message}" ]
113-
jiraAddComment site: 'JIRA', idOrKey: JIRA_ID, failOnError: false, input: comment
114-
mail charset: 'UTF-8', mimeType: 'text/html', to: "${emailList}", body: "${jira_email_body}", subject: "${message}: ${env.JOB_NAME} #${env.BUILD_NUMBER} - ${JIRA_ID}"
115-
} else {
116-
mail charset: 'UTF-8', mimeType: 'text/html', to: "${emailList}", body: "${email_body}", subject: "${message}: ${env.JOB_NAME} #${env.BUILD_NUMBER}"
134+
jiraAddComment site: 'JIRA',
135+
input: comment,
136+
idOrKey: JIRA_ID,
137+
failOnError: false
138+
email_body = "${email_body} <br/><br/><b>Jira URL: </b><br/><a href='${jira_link}'>${jira_link}</a>"
117139
}
140+
mail to: "${emailList}",
141+
body: "${email_body}",
142+
subject: "${message}: ${env.JOB_NAME} #${env.BUILD_NUMBER}",
143+
charset: 'UTF-8', mimeType: 'text/html'
118144
}
119145

120146
void copyRPMs() {
@@ -124,12 +150,22 @@ void copyRPMs() {
124150
RPMversion = "10.0"
125151
}
126152
else if (marklogicVersion == "11") {
127-
RPMsuffix = ".nightly-rhel"
153+
//if dockerImageType contains "ubi9" then use nightly-rhel9 suffix
154+
if (dockerImageType.contains("ubi9")) {
155+
RPMsuffix = ".nightly-rhel9"
156+
} else {
157+
RPMsuffix = ".nightly-rhel"
158+
}
128159
RPMbranch = "b11"
129160
RPMversion = "11.3"
130161
}
131162
else if (marklogicVersion == "12") {
132-
RPMsuffix = ".nightly-rhel"
163+
//if dockerImageType contains "ubi9" then use nightly-rhel9 suffix
164+
if (dockerImageType.contains("ubi9")) {
165+
RPMsuffix = ".nightly-rhel9"
166+
} else {
167+
RPMsuffix = ".nightly-rhel"
168+
}
133169
RPMbranch = "b12"
134170
RPMversion = "12.0"
135171
}
@@ -168,7 +204,7 @@ void buildDockerImage() {
168204
}
169205

170206
void pullUpgradeDockerImage() {
171-
if (dockerImageType == "ubi-rootless" ) {
207+
if (dockerImageType == "ubi-rootless" && params.DOCKER_TESTS != "true") {
172208
sh """
173209
echo 'dockerImageType is set to ubi-rootless, skipping this stage and Docker upgrade test.'
174210
"""
@@ -217,16 +253,14 @@ void lint() {
217253

218254
void vulnerabilityScan() {
219255
sh """
220-
make scan current_image=marklogic/marklogic-server-${dockerImageType}:${marklogicVersion}-${env.dockerImageType}-${env.dockerVersion} Jenkins=true
221-
grep \'High\\|Critical\' scan-server-image.txt
256+
make scan current_image=marklogic/marklogic-server-${dockerImageType}:${marklogicVersion}-${env.dockerImageType}-${env.dockerVersion} docker_image_type=${dockerImageType} Jenkins=true
222257
"""
223-
224-
SCAN_OUTPUT = sh(returnStdout: true, script: 'grep \'High\\|Critical\' scan-server-image.txt')
258+
SCAN_OUTPUT = sh(returnStdout: true, script: "cat scan/report-${env.dockerImageType}.txt")
259+
sh 'echo "SCAN_OUTPUT: ${SCAN_OUTPUT}"'
225260
if (SCAN_OUTPUT.size()) {
226-
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}"
261+
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}"
227262
}
228-
229-
sh '''rm -f scan-server-image.txt'''
263+
archiveArtifacts artifacts: 'scan/*', onlyIfSuccessful: true
230264
}
231265

232266
void publishToInternalRegistry() {
@@ -265,7 +299,31 @@ void publishToInternalRegistry() {
265299

266300
void publishTestResults() {
267301
junit allowEmptyResults:true, testResults: '**/test_results/docker-tests.xml,**/container-structure-test.xml'
268-
publishHTML allowMissing: true, alwaysLinkToLastBuild: true, keepAll: true, reportDir: 'test/test_results', reportFiles: 'report.html', reportName: 'Docker Tests Report', reportTitles: ''
302+
if (params.DOCKER_TESTS) {
303+
echo 'Publishing Docker results..'
304+
publishHTML allowMissing: false,
305+
alwaysLinkToLastBuild: true,
306+
keepAll: true,
307+
reportDir: 'test/test_results',
308+
reportFiles: 'report.html',
309+
reportName: 'Docker Tests Report',
310+
reportTitles: "Build ${env.BUILD_NUMBER}"
311+
}
312+
if (params.SCAP_SCAN) {
313+
echo 'Publishing SCAP scan results..'
314+
publishHTML allowMissing: false,
315+
alwaysLinkToLastBuild: true,
316+
keepAll: true, reportDir: 'scap',
317+
reportFiles: 'scap_scan_report.html',
318+
reportName: 'Open SCAP Report',
319+
reportTitles: "Build ${env.BUILD_NUMBER}"
320+
}
321+
}
322+
323+
void scapScan() {
324+
sh """
325+
make scap-scan current_image=marklogic/marklogic-server-${dockerImageType}:${marklogicVersion}-${env.dockerImageType}-${env.dockerVersion}
326+
"""
269327
}
270328

271329
pipeline {
@@ -280,31 +338,33 @@ pipeline {
280338
skipStagesAfterUnstable()
281339
}
282340
triggers {
283-
parameterizedCron( env.BRANCH_NAME == 'develop' ? '''00 02 * * * % marklogicVersion=11;dockerImageType=centos
341+
parameterizedCron( env.BRANCH_NAME == 'develop' ? '''00 02 * * * % marklogicVersion=10;dockerImageType=ubi
342+
00 02 * * * % marklogicVersion=10;dockerImageType=ubi-rootless;SCAP_SCAN=true
284343
00 02 * * * % marklogicVersion=11;dockerImageType=ubi
285-
00 02 * * * % marklogicVersion=11;dockerImageType=ubi-rootless
286-
30 02 * * * % marklogicVersion=10;dockerImageType=centos
287-
30 02 * * * % marklogicVersion=10;dockerImageType=ubi
288-
30 02 * * * % marklogicVersion=10;dockerImageType=ubi-rootless
289-
00 03 * * * % marklogicVersion=12;dockerImageType=centos
290-
00 03 * * * % marklogicVersion=12;dockerImageType=ubi
291-
00 03 * * * % marklogicVersion=12;dockerImageType=ubi-rootless''' : '')
344+
30 02 * * * % marklogicVersion=11;dockerImageType=ubi-rootless;SCAP_SCAN=true
345+
30 02 * * * % marklogicVersion=12;dockerImageType=ubi
346+
30 02 * * * % marklogicVersion=12;dockerImageType=ubi-rootless;SCAP_SCAN=true
347+
00 03 * * * % marklogicVersion=11;dockerImageType=ubi9
348+
00 03 * * * % marklogicVersion=11;dockerImageType=ubi9-rootless;SCAP_SCAN=true
349+
00 03 * * * % marklogicVersion=12;dockerImageType=ubi9
350+
00 03 * * * % marklogicVersion=12;dockerImageType=ubi9-rootless;SCAP_SCAN=true''' : '')
292351
}
293352
environment {
294353
QA_LICENSE_KEY = credentials('QA_LICENSE_KEY')
295354
}
296355

297356
parameters {
298357
string(name: 'emailList', defaultValue: emailList, description: 'List of email for build notification', trim: true)
299-
string(name: 'dockerVersion', defaultValue: '2.0.1', description: 'ML Docker version. This version along with ML rpm package version will be the image tag as {ML_Version}_{dockerVersion}', trim: true)
300-
choice(name: 'dockerImageType', choices: 'ubi-rootless\nubi\ncentos', description: 'Platform type for Docker image. Will be made part of the docker image tag')
358+
string(name: 'dockerVersion', defaultValue: '2.1.0', description: 'ML Docker version. This version along with ML rpm package version will be the image tag as {ML_Version}_{dockerVersion}', trim: true)
359+
choice(name: 'dockerImageType', choices: 'ubi-rootless\nubi\nubi9-rootless\nubi9', description: 'Platform type for Docker image. Will be made part of the docker image tag')
301360
string(name: 'upgradeDockerImage', defaultValue: '', description: 'Docker image for testing upgrades. Defaults to ubi image if left blank.\n Currently upgrading to ubi-rotless is not supported hence the test is skipped when ubi-rootless image is provided.', trim: true)
302361
choice(name: 'marklogicVersion', choices: '11\n12\n10', description: 'MarkLogic Server Branch. used to pick appropriate rpm')
303362
string(name: 'ML_RPM', defaultValue: '', description: 'URL for RPM to be used for Image creation. \n If left blank nightly ML rpm will be used.\n Please provide Jenkins accessible path e.g. /project/engineering or /project/qa', trim: true)
304363
string(name: 'ML_CONVERTERS', defaultValue: '', description: 'URL for the converters RPM to be included in the image creation \n If left blank the nightly ML Converters Package will be used.', trim: true)
305364
booleanParam(name: 'PUBLISH_IMAGE', defaultValue: false, description: 'Publish image to internal registry')
306365
booleanParam(name: 'TEST_STRUCTURE', defaultValue: true, description: 'Run container structure tests')
307366
booleanParam(name: 'DOCKER_TESTS', defaultValue: true, description: 'Run docker tests')
367+
booleanParam(name: 'SCAP_SCAN', defaultValue: false, description: 'Run Open SCAP scan on the image.')
308368
}
309369

310370
stages {
@@ -344,6 +404,15 @@ pipeline {
344404
}
345405
}
346406

407+
stage('SCAP-Scan') {
408+
when {
409+
expression { return params.SCAP_SCAN }
410+
}
411+
steps {
412+
scapScan()
413+
}
414+
}
415+
347416
stage('Structure-Tests') {
348417
when {
349418
expression { return params.TEST_STRUCTURE }
@@ -374,17 +443,18 @@ pipeline {
374443
build job: 'MarkLogic-Docker-Kubernetes/docker/docker-nightly-builds-qa', wait: false, parameters: [string(name: 'dockerImageType', value: "${dockerImageType}"), string(name: 'marklogicVersion', value: "${RPMversion}")]
375444
}
376445
}
446+
377447
}
378448

379449
post {
380450
always {
381451
sh '''
382452
cd src
383-
rm -rf *.rpm
384-
docker rm -f $(docker ps -a -q) || true
385-
docker system prune --force --filter "until=720h"
386-
docker volume prune --force
387-
docker image prune --force --all
453+
rm -rf *.rpm NOTICE.txt
454+
docker stop $(docker ps -a -q) || true
455+
docker system prune --force --all
456+
docker volume prune --force --all
457+
docker system df
388458
'''
389459
publishTestResults()
390460
}

0 commit comments

Comments
 (0)