diff --git a/.ci/jenkins/Jenkinsfile.setup-branch b/.ci/jenkins/Jenkinsfile.setup-branch index ade24b156..e6d5b1027 100644 --- a/.ci/jenkins/Jenkinsfile.setup-branch +++ b/.ci/jenkins/Jenkinsfile.setup-branch @@ -103,8 +103,14 @@ pipeline { steps { script { dir(getRepoName()) { + githubscm.setUserConfigFromCreds(getGitAuthorPushCredsId()) + def mainBranchPrCheckJenkinsfile = '.ci/jenkins/Jenkinsfile' + def newBranchPrCheckJenkinsfile = ".ci/jenkins/Jenkinsfile.pr.${getBuildBranch()}" + if (!isMainBranch() && fileExists(mainBranchPrCheckJenkinsfile)) { + sh "mv ${mainBranchPrCheckJenkinsfile} ${newBranchPrCheckJenkinsfile}" + sh "git add ${newBranchPrCheckJenkinsfile}" + } if (githubscm.isThereAnyChanges()) { - githubscm.setUserConfigFromCreds(getGitAuthorPushCredsId()) githubscm.commitChanges("[${getBuildBranch()}] Update version to ${getKogitoVersion()}") githubscm.pushObject('origin', getBuildBranch(), getGitAuthorPushCredsId()) } else { diff --git a/.ci/jenkins/dsl/jobs.groovy b/.ci/jenkins/dsl/jobs.groovy index c3eb80a02..526ad3130 100644 --- a/.ci/jenkins/dsl/jobs.groovy +++ b/.ci/jenkins/dsl/jobs.groovy @@ -64,7 +64,8 @@ void setupPrJob() { setupBuildAndTestJob(JobType.PULL_REQUEST) // Branch Source Plugin multibranchPipelineJob - Utils.isMainBranch(this) && KogitoJobTemplate.createPullRequestMultibranchPipelineJob(this, "${jenkins_path}/Jenkinsfile", JobType.PULL_REQUEST.getName()) + def triggeringJenkinsfileName = Utils.isMainBranch(this) ? "Jenkinsfile" : "Jenkinsfile.pr.${Utils.getGitBranch(this)}" + KogitoJobTemplate.createPullRequestMultibranchPipelineJob(this, "${jenkins_path}/${triggeringJenkinsfileName}", JobType.PULL_REQUEST.getName()) } void createSetupBranchJob() {