From c1b177f92bf71d49fd47dee086ddeebb733ab3ad Mon Sep 17 00:00:00 2001 From: Wen Zhou Date: Thu, 5 Jan 2023 10:31:13 +0100 Subject: [PATCH] fix: release pipeline checkout by tag not branch need special handle in jenkins git plugin (#562) --- pipelines/build/common/config_regeneration.groovy | 5 +++++ pipelines/build/common/create_job_from_template.groovy | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/pipelines/build/common/config_regeneration.groovy b/pipelines/build/common/config_regeneration.groovy index e3fd28584..e278b112c 100644 --- a/pipelines/build/common/config_regeneration.groovy +++ b/pipelines/build/common/config_regeneration.groovy @@ -525,6 +525,11 @@ class Regeneration implements Serializable { params.put('PR_BUILDER', true) } + // Makre sure the dsl knows if we are building for release job which checkout by a tag not branch + if (jobType == "release") { + params.put('CHECKOUT_AS_TAG', true) // in dsl, we convert GIT_BRANCH to a tag then checkout + } + // Execute job dsl, using adopt's template if the user doesn't have one def create = null try { diff --git a/pipelines/build/common/create_job_from_template.groovy b/pipelines/build/common/create_job_from_template.groovy index 60934309a..d0253e7da 100644 --- a/pipelines/build/common/create_job_from_template.groovy +++ b/pipelines/build/common/create_job_from_template.groovy @@ -28,6 +28,10 @@ if (!binding.hasVariable('GIT_BRANCH')) { GIT_BRANCH = 'master' } +if (binding.hasVariable('CHECKOUT_AS_TAG')) { + GIT_BRANCH = "refs/tags/"+GIT_BRANCH +} + isLightweight = true if (binding.hasVariable('PR_BUILDER')) { isLightweight = false