From df87fea792d3c03281f1a9cff314c32e7bff3e89 Mon Sep 17 00:00:00 2001 From: Yuxiang Zhu Date: Feb 28 2019 03:10:19 +0000 Subject: CI/CD: Fix `scratch` field in ci.container-image.test.complete messages Following up https://pagure.io/waiverdb/pull-request/282. This PR changes the pagure polling job to pass the original branch name rather than commit ID to `waiverdb-dev` job on master branch changes. `waiverdb-dev` then passes commit ID to downstream container build and integration test jobs to ensure the exact same commit is processed. --- diff --git a/openshift/pipelines/templates/waiverdb-dev.Jenkinsfile b/openshift/pipelines/templates/waiverdb-dev.Jenkinsfile index 4314d0b..97ff1ce 100644 --- a/openshift/pipelines/templates/waiverdb-dev.Jenkinsfile +++ b/openshift/pipelines/templates/waiverdb-dev.Jenkinsfile @@ -87,6 +87,7 @@ pipeline { branches: [[name: params.WAIVERDB_GIT_REF]], userRemoteConfigs: [[url: params.WAIVERDB_GIT_REPO, refspec: '+refs/heads/*:refs/remotes/origin/* +refs/pull/*/head:refs/remotes/origin/pull/*/head']], ]) + env.WAIVERDB_GIT_COMMIT = scmVars.GIT_COMMIT // Generate a version-release number for the target Git commit def versions = sh(returnStdout: true, script: 'source ./version.sh && echo -en "$WAIVERDB_VERSION\n$WAIVERDB_CONTAINER_VERSION"').split('\n') env.WAIVERDB_VERSION = versions[0] @@ -219,7 +220,7 @@ pipeline { def processed = openshift.process(template, "-p", "NAME=${env.BUILDCONFIG_INSTANCE_ID}", '-p', "WAIVERDB_GIT_REPO=${params.WAIVERDB_GIT_REPO}", - '-p', "WAIVERDB_GIT_REF=${params.WAIVERDB_GIT_REF}", + '-p', "WAIVERDB_GIT_REF=${params.WAIVERDB_GIT_REF == params.WAIVERDB_MAIN_BRANCH ? env.WAIVERDB_GIT_COMMIT : params.WAIVERDB_GIT_REF}", '-p', "WAIVERDB_IMAGE_TAG=${env.TEMP_TAG}", '-p', "WAIVERDB_VERSION=${env.WAIVERDB_VERSION}", '-p', "WAIVERDB_IMAGESTREAM_NAME=${params.WAIVERDB_IMAGESTREAM_NAME}", @@ -290,7 +291,7 @@ pipeline { def buildSelector = testBcSelector.startBuild( '-e', "IMAGE=${env.RESULTING_IMAGE_REPO}:${env.RESULTING_TAG}", '-e', "WAIVERDB_GIT_REPO=${params.WAIVERDB_GIT_REPO}", - '-e', "WAIVERDB_GIT_REF=${params.WAIVERDB_GIT_REF}", + '-e', "WAIVERDB_GIT_REF=${params.WAIVERDB_GIT_REF == params.WAIVERDB_MAIN_BRANCH ? env.WAIVERDB_GIT_COMMIT : params.WAIVERDB_GIT_REF}", '-e', "IMAGE_IS_SCRATCH=${params.WAIVERDB_GIT_REF != params.WAIVERDB_MAIN_BRANCH}", ) echo 'Waiting for the integration test result...' diff --git a/openshift/pipelines/templates/waiverdb-polling-pagure.yaml b/openshift/pipelines/templates/waiverdb-polling-pagure.yaml index a8b0eb0..765d833 100644 --- a/openshift/pipelines/templates/waiverdb-polling-pagure.yaml +++ b/openshift/pipelines/templates/waiverdb-polling-pagure.yaml @@ -225,12 +225,9 @@ objects: openshift.withProject("${DEV_PIPELINE_BC_NAMESPACE}") { def bcSelector = openshift.selector('bc', "${DEV_PIPELINE_BC_NAME}") echo 'Starting a dev pipeline build...' - def isMaster = env.PAGURE_POLLING_FOR_PR != 'true' def devBuild = bcSelector.startBuild( '-e', "WAIVERDB_GIT_REPO=${env.GIT_URL}", - '-e', "WAIVERDB_GIT_REF=${isMaster? env.GIT_COMMIT : env.GIT_BRANCH}", - '-e', "FORCE_PUBLISH_IMAGE=${isMaster}", - '-e', "FORCE_PUBLISH_DOCS=${isMaster}", + '-e', "WAIVERDB_GIT_REF=${env.GIT_BRANCH}", '-e', "WAIVERDB_MAIN_BRANCH=${PAGURE_POLLED_BRANCH}", '-e', "BUILD_DISPLAY_RENAME_TO=${currentBuild.displayName}", )