This is an automated email from the ASF dual-hosted git repository.
jstastnycz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-drools.git
The following commit(s) were added to refs/heads/main by this push:
new 0d64110e6d kie-issues#776: automate PR merge into protected branches
0d64110e6d is described below
commit 0d64110e6d19fe20442d48427b12de091aa39e5b
Author: jstastny-cz <[email protected]>
AuthorDate: Fri May 10 11:12:16 2024 +0200
kie-issues#776: automate PR merge into protected branches
---
.ci/jenkins/Jenkinsfile.promote | 16 ++++++++--------
.ci/jenkins/Jenkinsfile.setup-branch | 15 ---------------
.ci/jenkins/project/Jenkinsfile.post-release | 12 +++++-------
3 files changed, 13 insertions(+), 30 deletions(-)
diff --git a/.ci/jenkins/Jenkinsfile.promote b/.ci/jenkins/Jenkinsfile.promote
index 32c74027f0..2fb1959336 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 e874d3020b..8a445803a3 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 af08898f0e..4e054a3a6f 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())
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]