From 018dfc82a8e8ec0f6cb5e649e8d7870d4c40e009 Mon Sep 17 00:00:00 2001 From: Yuxiang Zhu Date: Dec 13 2018 10:04:45 +0000 Subject: CI/CD - Sending integration test results to UMB This PR will introduce the JMS messaging plugin[2] to send integration test results to UMB with [the proposed message spec][1]. [1]: https://pagure.io/fedora-ci/messages/pull-request/18 [2]: https://github.com/jenkinsci/jms-messaging-plugin --- diff --git a/openshift/README.md b/openshift/README.md index 7ad96f6..b298cea 100644 --- a/openshift/README.md +++ b/openshift/README.md @@ -19,6 +19,7 @@ Before using the Pipeline, please ensure your Jenkins master has the following p - [SSH Agent plugin][] - [Email Extension plugin][] - [Ownership plugin][] +- [JMS Messaging plugin][] Notes: [1]: Those plugins are preinstalled if you are using the Jenkins master shipped with OpenShift. @@ -287,5 +288,6 @@ You can go to the OpenShift Web console for more details of the pipeline build. [SSH Agent plugin]: https://github.com/jenkinsci/ssh-agent-plugin [Email Extension plugin]: https://github.com/jenkinsci/email-ext-plugin [Ownership plugin]: https://github.com/jenkinsci/ownership-plugin +[JMS Messaging plugin]: https://github.com/jenkinsci/jms-messaging-plugin [OpenShift secret for registries]:https://docs.openshift.com/container-platform/3.9/dev_guide/builds/build_inputs.html#using-docker-credentials-for-private-registries [OpenShift secret for SSH key authentication]: https://docs.openshift.com/container-platform/3.9/dev_guide/builds/build_inputs.html#source-secrets-ssh-key-authentication diff --git a/openshift/pipelines/templates/waiverdb-integration-test.Jenkinsfile b/openshift/pipelines/templates/waiverdb-integration-test.Jenkinsfile index 62a6aa3..265c0e7 100644 --- a/openshift/pipelines/templates/waiverdb-integration-test.Jenkinsfile +++ b/openshift/pipelines/templates/waiverdb-integration-test.Jenkinsfile @@ -90,6 +90,7 @@ pipeline { openshift.withCluster() { def imageTag = (params.IMAGE =~ /(?::(\w[\w.-]{0,127}))?$/)[0][1] def imageRepo = imageTag ? params.IMAGE.substring(0, params.IMAGE.length() - imageTag.length() - 1) : params.IMAGE + env.IMAGE_TAG = imageTag ?: 'latest' def template = readYaml file: 'openshift/waiverdb-test-template.yaml' def webPodReplicas = 1 // The current quota in UpShift is agressively limited def models = openshift.process(template, @@ -121,6 +122,8 @@ pipeline { error("Test pod ${pod.metadata.name} is not running. Current phase is ${pod.status.phase}.") } } + def appPod = openshift.selector('pods', ['environment': env.ENVIRONMENT_LABEL, 'service': 'web']).object() + env.IMAGE_DIGEST = appPod.status.containerStatuses[0].imageID.split('@')[1] // Run functional tests def route_hostname = objects.narrow('route').object().spec.host echo "Running tests against https://${route_hostname}/" @@ -134,6 +137,7 @@ pipeline { always { script { junit 'junit-functional-tests.xml' + archiveArtifacts artifacts: 'junit-functional-tests.xml' openshift.withCluster() { /* Extract logs for debugging purposes */ openshift.selector('deploy,pods', ['environment': env.ENVIRONMENT_LABEL]).logs() @@ -152,9 +156,57 @@ pipeline { } } } - stage('Report to ResultsDB') { - steps { - echo 'This is a placeholder.' + } + post { + always { + script { + def sendResult = sendCIMessage \ + providerName: 'Red Hat UMB', \ + overrides: [topic: 'VirtualTopic.eng.ci.container-image.test.complete'], \ + messageType: 'Custom', \ + messageProperties: '', \ + messageContent: """ + { + "ci": { + "name": "C3I Jenkins", + "team": "DevOps", + "url": "${env.JENKINS_URL}", + "docs": "https://pagure.io/waiverdb/blob/master/f/openshift", + "irc": "#pnt-devops-dev", + "email": "pnt-factory2-devel@redhat.com", + "environment": "development" + }, + "run": { + "url": "${env.BUILD_URL}", + "log": "${env.BUILD_URL}/console", + "debug": "", + "rebuild": "${env.BUILD_URL}/rebuild/parametrized" + }, + "artifact": { + "type": "container-image", + "repository": "factory2/waiverdb", + "digest": "${env.IMAGE_DIGEST}", + "nvr": "waiverdb:${env.IMAGE_TAG}", + "issuer": "c3i-jenkins", + "scratch": true + }, + "system": + [{ + "os": "${params.JENKINS_AGENT_IMAGE}", + "provider": "openshift", + "architecture": "x86_64" + }], + "type": "tier1", + "category": "integration", + "status": "${currentBuild.result == 'SUCCESS' ? 'passed':'failed'}", + "xunit": "${env.BUILD_URL}/artifacts/junit-functional-tests.xml", + "namespace": "waiverdb-test", + "version": "0.1.0" + } + """ + // echo sent message id and content + echo sendResult.getMessageId() + echo sendResult.getMessageContent() } } }