diff --git a/.ci/jenkins/Jenkinsfile.promote b/.ci/jenkins/Jenkinsfile.promote index 32c74027f04..2fb19593364 100644 --- a/.ci/jenkins/Jenkinsfile.promote +++ b/.ci/jenkins/Jenkinsfile.promote @@ -64,8 +64,8 @@ pipeline { steps { script { dir(getRepoName()) { + approveAndMergePR(getDeployPrLink()) checkoutRepo() - mergeAndPush(getDeployPrLink()) tagLatest() } } @@ -78,10 +78,10 @@ pipeline { dir(getRepoName()) { checkoutRepo() if(githubscm.isReleaseExist(getGitTag(), getGitAuthorCredsId())) { - githubscm.deleteRelease(getGitTag(), getGitAuthorCredsId()) + githubscm.deleteRelease(getGitTag(), getGitAuthorPushCredsId()) } - githubscm.createReleaseWithGeneratedReleaseNotes(getGitTag(), getBuildBranch(), githubscm.getPreviousTagFromVersion(getGitTag()), getGitAuthorCredsId()) - githubscm.updateReleaseBody(getGitTag(), getGitAuthorCredsId()) + githubscm.createReleaseWithGeneratedReleaseNotes(getGitTag(), getBuildBranch(), githubscm.getPreviousTagFromVersion(getGitTag()), getGitAuthorPushCredsId()) + githubscm.updateReleaseBody(getGitTag(), getGitAuthorPushCredsId()) } } } @@ -210,10 +210,10 @@ void checkoutRepo() { sh "git checkout ${getBuildBranch()}" } -void mergeAndPush(String prLink) { - if (prLink) { - githubscm.mergePR(prLink, getGitAuthorCredsId()) - githubscm.pushObject('origin', getBuildBranch(), getGitAuthorPushCredsId()) +void approveAndMergePR(String prLink) { + if (prLink?.trim()) { + githubscm.approvePR(prLink, getGitAuthorPushCredsId()) + githubscm.mergePR(prLink, getGitAuthorPushCredsId()) } } diff --git a/.ci/jenkins/Jenkinsfile.setup-branch b/.ci/jenkins/Jenkinsfile.setup-branch index e874d3020bb..8a445803a32 100644 --- a/.ci/jenkins/Jenkinsfile.setup-branch +++ b/.ci/jenkins/Jenkinsfile.setup-branch @@ -164,21 +164,6 @@ boolean isMainBranch() { return env.IS_MAIN_BRANCH ? env.IS_MAIN_BRANCH.toBoolean() : false } -String commitAndCreatePR(String commitMsg, String localBranch, String targetBranch) { - def prBody = "Generated by build ${BUILD_TAG}: ${BUILD_URL}" - githubscm.setUserConfigFromCreds(getGitAuthorPushCredsId()) - githubscm.commitChanges(commitMsg) - githubscm.pushObject('origin', localBranch, getGitAuthorPushCredsId()) - return githubscm.createPR(commitMsg, prBody, targetBranch, getGitAuthorCredsId()) -} - -void mergeAndPush(String prLink, String targetBranch) { - if (prLink?.trim()) { - githubscm.mergePR(prLink, getGitAuthorCredsId()) - githubscm.pushObject('origin', targetBranch, getGitAuthorPushCredsId()) - } -} - boolean isMainStream() { return env.DROOLS_STREAM == 'main' } diff --git a/.ci/jenkins/project/Jenkinsfile.post-release b/.ci/jenkins/project/Jenkinsfile.post-release index af08898f0e8..4e054a3a6fd 100644 --- a/.ci/jenkins/project/Jenkinsfile.post-release +++ b/.ci/jenkins/project/Jenkinsfile.post-release @@ -69,9 +69,7 @@ pipeline { sh 'mvn clean generate-resources' // Add changed files, commit, open and merge PR prLink = commitAndCreatePR("Upgrade drools-website ${getProjectVersion()}", prBranchName, getBuildBranch()) - sh "git checkout ${getBuildBranch()}" - mergeAndPush(prLink, getBuildBranch()) - githubscm.removeRemoteBranch('origin', prBranchName, getGitAuthorPushCredsId()) + approveAndMergePR(prLink) } } } @@ -134,10 +132,10 @@ void checkoutRepo(String repo, String branch) { sh "git checkout ${branch}" } -void mergeAndPush(String prLink, String targetBranch) { - if (prLink != '') { - githubscm.mergePR(prLink, getGitAuthorCredsId()) - githubscm.pushObject('origin', targetBranch, getGitAuthorPushCredsId()) +void approveAndMergePR(String prLink) { + if (prLink?.trim()) { + githubscm.approvePR(prLink, getGitAuthorPushCredsId()) + githubscm.mergePR(prLink, getGitAuthorPushCredsId()) } }