From 590b6121caa1dadfc13bec96b5259f3e02579d4c Mon Sep 17 00:00:00 2001 From: Yuxiang Zhu Date: Mar 06 2019 03:57:33 +0000 Subject: CI/CD: enhancements to integration test jobs 1. Allow to customize messaging providers for C3I debugging purpose. 2. Don't send a message when jobs fail before getting a valid image digest. 3. Print error if failing to send a message. --- diff --git a/openshift/pipelines/templates/waiverdb-integration-test-template.yaml b/openshift/pipelines/templates/waiverdb-integration-test-template.yaml index 2566cec..bc7d168 100644 --- a/openshift/pipelines/templates/waiverdb-integration-test-template.yaml +++ b/openshift/pipelines/templates/waiverdb-integration-test-template.yaml @@ -43,6 +43,9 @@ parameters: displayName: environment name (dev/stage/prod) required: true value: dev +- name: MESSAGING_PROVIDER + displayName: Name of the JMS messaging provider + value: Red Hat UMB objects: - kind: ServiceAccount apiVersion: v1 @@ -98,4 +101,6 @@ objects: value: "${NAME}-jenkins-slave" - name: ENVIRONMENT value: "${ENVIRONMENT}" + - name: MESSAGING_PROVIDER + value: "${MESSAGING_PROVIDER}" jenkinsfilePath: openshift/pipelines/templates/waiverdb-integration-test.Jenkinsfile diff --git a/openshift/pipelines/templates/waiverdb-integration-test.Jenkinsfile b/openshift/pipelines/templates/waiverdb-integration-test.Jenkinsfile index 840f043..b602cac 100644 --- a/openshift/pipelines/templates/waiverdb-integration-test.Jenkinsfile +++ b/openshift/pipelines/templates/waiverdb-integration-test.Jenkinsfile @@ -160,11 +160,15 @@ pipeline { post { always { script { + if (!env.IMAGE_DIGEST) { + // Don't send a message if the job fails before getting the image digest. + return; + } // currentBuild.result == null || currentBuild.result == 'SUCCESS' indicates a successful build, // because it's possible that the pipeline engine hasn't set the value nor seen an error when reaching to this line. // See example code in https://jenkins.io/doc/book/pipeline/jenkinsfile/#deploy def sendResult = sendCIMessage \ - providerName: 'Red Hat UMB', \ + providerName: params.MESSAGING_PROVIDER, \ overrides: [topic: 'VirtualTopic.eng.ci.container-image.test.complete'], \ messageType: 'Custom', \ messageProperties: '', \ @@ -209,9 +213,14 @@ pipeline { "version": "0.1.0" } """ - // echo sent message id and content - echo sendResult.getMessageId() - echo sendResult.getMessageContent() + if (sendResult.getMessageId()) { + // echo sent message id and content + echo 'Successfully sent the test result to ResultsDB.' + echo "Message ID: ${sendResult.getMessageId()}" + echo "Message content: ${sendResult.getMessageContent()}" + } else { + echo 'Failed to sent the test result to ResultsDB.' + } } } }