| |
@@ -209,3 +209,79 @@
|
| |
])
|
| |
}
|
| |
}
|
| |
+
|
| |
+ /**
|
| |
+ * Send message with container testing results.
|
| |
+ * @param args.imageRepo Name of the image.
|
| |
+ * @param args.imageDigest Digest of the image.
|
| |
+ * @param args.imageVerRel Version of the image. E.g. 1.2.3-1
|
| |
+ * @param args.imageIsScratchBuild Boolean value.
|
| |
+ * @param args.provider UMB provider name defined in Jenkins.
|
| |
+ * @return Result from sendCIMessage.
|
| |
+ */
|
| |
+
|
| |
+ def sendResultToMessageBus(
|
| |
+ String imageRepo, // e.g. 'waiverdb'
|
| |
+ String imageDigest, // e.g. 'sha256:79bd800433a1965d970dfa17b518c3b58e1e1c1528df77900d57c0fbc7dd5949'
|
| |
+ String imageVerRel, // e.g. '1.2.3-1'
|
| |
+ boolean imageIsScratchBuild = true,
|
| |
+ String provider = 'Red Hat UMB'
|
| |
+ ) {
|
| |
+ // 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: provider, \
|
| |
+ overrides: [topic: 'VirtualTopic.eng.ci.container-image.test.complete'], \
|
| |
+ messageType: 'Custom', \
|
| |
+ messageProperties: '', \
|
| |
+ messageContent: """
|
| |
+ {
|
| |
+ "version": "0.1.0",
|
| |
+ "ci": {
|
| |
+ "name": "C3I Jenkins",
|
| |
+ "team": "DevOps",
|
| |
+ "url": "${env.JENKINS_URL}",
|
| |
+ "docs": "https://gitlab.cee.redhat.com/devops/factory2-segment-tests/tree/master/integration-test",
|
| |
+ "irc": "#pnt-devops-dev",
|
| |
+ "email": "pnt-factory2-devel@redhat.com",
|
| |
+ "environment": "stage"
|
| |
+ },
|
| |
+ "run": {
|
| |
+ "url": "${env.BUILD_URL}",
|
| |
+ "log": "${env.BUILD_URL}/console",
|
| |
+ "debug": "",
|
| |
+ "rebuild": "${env.BUILD_URL}/rebuild/parametrized"
|
| |
+ },
|
| |
+ "artifact": {
|
| |
+ "type": "container-image",
|
| |
+ "repository": "${imageRepo}",
|
| |
+ "digest": "${imageDigest}",
|
| |
+ "nvr": "${imageRepo}:${imageVerRel}",
|
| |
+ "issuer": "c3i-jenkins",
|
| |
+ "scratch": ${imageIsScratchBuild},
|
| |
+ "id": "${imageRepo}@${imageDigest}"
|
| |
+ },
|
| |
+ "system":
|
| |
+ [{
|
| |
+ "os": "${env.JENKINS_AGENT_IMAGE}",
|
| |
+ "provider": "openshift",
|
| |
+ "architecture": "x86_64"
|
| |
+ }],
|
| |
+ "type": "integration",
|
| |
+ "category": "${env.TESTCASE_CATEGORY}",
|
| |
+ "status": "${currentBuild.result == null || currentBuild.result == 'SUCCESS' ? 'passed':'failed'}",
|
| |
+ "generated_at": "${new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'", TimeZone.getTimeZone('UTC'))}",
|
| |
+ "namespace": "c3i",
|
| |
+ "version": "0.1.0"
|
| |
+ }
|
| |
+ """
|
| |
+ 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.'
|
| |
+ }
|
| |
+ }
|
| |
Method for sending results of tested images. Used in
factory2-segment-tests, moving to allow use it by multiple projects.