From cfabe78a59512aa45876b15bb9a053c3e3ca28a9 Mon Sep 17 00:00:00 2001 From: Michal Kovarik Date: Nov 05 2019 12:16:38 +0000 Subject: Do premerge testing with Jenkins files from the PR Varibales for git checkout (WAIVERDB_GIT_REPO, WAIVERDB_GIT_BRANCH) were evaluated during openshift template applications. Which caused that PRs were tested with Jenkins file in master branch intead of PR ones. Openshift BuildConfig is not able to specify git refs to be fetched and PR refs are not available, to avoid this issue WAIVERDB_GIT_REF_COMMIT contains SHA of last PR (or can be master branch). --- diff --git a/openshift/pipelines/templates/waiverdb-build-template.yaml b/openshift/pipelines/templates/waiverdb-build-template.yaml index 27c423a..7ef982a 100644 --- a/openshift/pipelines/templates/waiverdb-build-template.yaml +++ b/openshift/pipelines/templates/waiverdb-build-template.yaml @@ -41,6 +41,11 @@ parameters: description: Default WaiverDB Git repo ref in which to run dev tests against required: true value: master +- name: WAIVERDB_GIT_REF_COMMIT + displayName: WaiverDB Git repo ref reachable by Jenkins + description: Default WaiverDB Git repo ref in which to get Jenkins pipeline file + required: true + value: master - name: WAIVERDB_MAIN_BRANCH displayName: Name of the main branch. description: If WAIVERDB_MAIN_BRANCH equals WAIVERDB_GIT_REF, this is a post-merge build, otherwise it's a pre-merge build. @@ -178,8 +183,9 @@ objects: completionDeadlineSeconds: 1800 source: git: - uri: "${WAIVERDB_GIT_REPO}" - ref: "${WAIVERDB_MAIN_BRANCH}" + # Using jenkins variable, not template + uri: "$WAIVERDB_GIT_REPO" + ref: "$WAIVERDB_GIT_REF_COMMIT" strategy: type: JenkinsPipeline jenkinsPipelineStrategy: @@ -188,6 +194,8 @@ objects: value: "${WAIVERDB_GIT_REPO}" - name: "WAIVERDB_GIT_REF" value: "${WAIVERDB_GIT_REF}" + - name: "WAIVERDB_GIT_REF_COMMIT" + value: "${WAIVERDB_GIT_REF_COMMIT}" - name: "JENKINS_AGENT_CLOUD_NAME" value: "${JENKINS_AGENT_CLOUD_NAME}" - name: "JENKINS_AGENT_IMAGE" diff --git a/openshift/pipelines/templates/waiverdb-integration-test-template.yaml b/openshift/pipelines/templates/waiverdb-integration-test-template.yaml index 696f9e4..0a02c61 100644 --- a/openshift/pipelines/templates/waiverdb-integration-test-template.yaml +++ b/openshift/pipelines/templates/waiverdb-integration-test-template.yaml @@ -27,6 +27,11 @@ parameters: description: Default WaiverDB Git repo ref in which to run functional tests against required: true value: master +- name: WAIVERDB_GIT_REF_COMMIT + displayName: WaiverDB Git repo ref reachable by Jenkins + description: Default WaiverDB Git repo ref in which to get Jenkins pipeline file + required: true + value: master - name: JENKINS_AGENT_IMAGE displayName: Container image for Jenkins slave pods required: true @@ -75,8 +80,9 @@ objects: completionDeadlineSeconds: 1800 source: git: - uri: "${WAIVERDB_GIT_REPO}" - ref: "${WAIVERDB_GIT_REF}" + # Using jenkins variable, not template + uri: "$WAIVERDB_GIT_REPO" + ref: "$WAIVERDB_GIT_REF_COMMIT" strategy: type: JenkinsPipeline jenkinsPipelineStrategy: @@ -85,6 +91,8 @@ objects: value: "${WAIVERDB_GIT_REPO}" - name: "WAIVERDB_GIT_REF" value: "${WAIVERDB_GIT_REF}" + - name: "WAIVERDB_GIT_REF_COMMIT" + value: "${WAIVERDB_GIT_REF_COMMIT}" - name: "IMAGE" value: "${IMAGE}" - name: IMAGE_IS_SCRATCH diff --git a/openshift/pipelines/templates/waiverdb-polling-pagure.yaml b/openshift/pipelines/templates/waiverdb-polling-pagure.yaml index 8280bb9..d56b737 100644 --- a/openshift/pipelines/templates/waiverdb-polling-pagure.yaml +++ b/openshift/pipelines/templates/waiverdb-polling-pagure.yaml @@ -218,6 +218,7 @@ objects: def bc = env.PAGURE_POLLING_FOR_PR == 'true' ? env.PREMERGE_JOB_NAME : env.POSTMERGE_JOB_NAME def build = c3i.build(script: this, objs: "bc/${bc}", '-e', "WAIVERDB_GIT_REF=${env.WAIVERDB_GIT_BRANCH}", + '-e', "WAIVERDB_GIT_REF_COMMIT=${env.WAIVERDB_GIT_COMMIT}", ) c3i.waitForBuildStart(script: this, build: build) def devBuildInfo = build.object()