From d108dc046ff8ee921f7d302f09b7b389bec23373 Mon Sep 17 00:00:00 2001 From: jstastny-cz Date: Fri, 10 May 2024 09:45:23 +0200 Subject: [PATCH] kie-issues#776: automate PR merge into protected branches --- .ci/jenkins/Jenkinsfile.bump-up-version | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.ci/jenkins/Jenkinsfile.bump-up-version b/.ci/jenkins/Jenkinsfile.bump-up-version index ed8c38e5..bc53d72e 100644 --- a/.ci/jenkins/Jenkinsfile.bump-up-version +++ b/.ci/jenkins/Jenkinsfile.bump-up-version @@ -45,9 +45,7 @@ pipeline { githubscm.createBranch(localBranch) maven.mvnSetVersionProperty("version.org.${getUpdateRepoName()}", getVersion()) String prLink = commitAndCreatePR(commitMsg, localBranch, "${getTargetBranch()}") - sh "git checkout ${getTargetBranch()}" - mergeAndPush(prLink, "${getTargetBranch()}") - githubscm.removeRemoteBranch('origin', localBranch, getGitAuthorPushCredsId()) + approveAndMergePR(prLink) } } } @@ -96,13 +94,12 @@ String commitAndCreatePR(String commitMsg, String localBranch, String targetBran githubscm.setUserConfigFromCreds(getGitAuthorPushCredsId()) githubscm.commitChanges(commitMsg) githubscm.pushObject('origin', localBranch, getGitAuthorPushCredsId()) - return githubscm.createPR(commitMsg, prBody, targetBranch,getGitAuthorCredsId()) + return githubscm.createPR(commitMsg, prBody, targetBranch, getGitAuthorCredsId()) } -void mergeAndPush(String prLink, String targetBranch) { +void approveAndMergePR(String prLink) { if (prLink?.trim()) { - githubscm.mergePR(prLink, getGitAuthorCredsId()) - githubscm.pushObject('origin', targetBranch, getGitAuthorPushCredsId()) + githubscm.approvePR(prLink, getGitAuthorPushCredsId()) + githubscm.mergePR(prLink, getGitAuthorPushCredsId()) } } -