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-optaplanner.git
The following commit(s) were added to refs/heads/main by this push:
new 0ed60102d6 kie-issues#776: automate PR merge into protected branches
0ed60102d6 is described below
commit 0ed60102d6cea823074b7818475626692221b14a
Author: jstastny-cz <[email protected]>
AuthorDate: Fri May 10 12:30:32 2024 +0200
kie-issues#776: automate PR merge into protected branches
---
.ci/jenkins/Jenkinsfile.promote | 32 ++++++++++++----------------
.ci/jenkins/Jenkinsfile.setup-branch | 15 -------------
.ci/jenkins/project/Jenkinsfile.nightly | 2 +-
.ci/jenkins/project/Jenkinsfile.post-release | 10 ++++-----
4 files changed, 20 insertions(+), 39 deletions(-)
diff --git a/.ci/jenkins/Jenkinsfile.promote b/.ci/jenkins/Jenkinsfile.promote
index 32a9c29b32..752034412b 100644
--- a/.ci/jenkins/Jenkinsfile.promote
+++ b/.ci/jenkins/Jenkinsfile.promote
@@ -77,15 +77,15 @@ pipeline {
steps {
script {
dir(optaplannerRepository) {
+
approveAndMergePR(getDeployPrLink(optaplannerRepository))
checkoutRepo(optaplannerRepository)
- mergeAndPush(getDeployPrLink(optaplannerRepository))
tagLatest()
- if(githubscm.isReleaseExist(getGitTag(),
getGitAuthorCredsId())) {
- githubscm.deleteRelease(getGitTag(),
getGitAuthorCredsId())
+ if (githubscm.isReleaseExist(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())
}
}
}
@@ -95,15 +95,15 @@ pipeline {
steps {
script {
dir(quickstartsRepository) {
+
approveAndMergePR(getDeployPrLink(quickstartsRepository))
checkoutRepo(quickstartsRepository)
- mergeAndPush(getDeployPrLink(quickstartsRepository))
tagLatest()
- if(githubscm.isReleaseExist(getGitTag(),
getGitAuthorCredsId())) {
- githubscm.deleteRelease(getGitTag(),
getGitAuthorCredsId())
+ if (githubscm.isReleaseExist(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())
}
}
}
@@ -238,17 +238,13 @@ void checkoutRepo(String repo) {
sh "git checkout ${getBuildBranch()}"
}
-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())
}
}
-void mergeAndPush(String prLink) {
- mergeAndPush(prLink, getBuildBranch())
-}
-
void tagLatest() {
if (getGitTag() != '') {
githubscm.tagLocalAndRemoteRepository('origin', getGitTag(),
getGitAuthorPushCredsId(), env.BUILD_TAG, true)
diff --git a/.ci/jenkins/Jenkinsfile.setup-branch
b/.ci/jenkins/Jenkinsfile.setup-branch
index aff96e46b9..d210e9c40c 100644
--- a/.ci/jenkins/Jenkinsfile.setup-branch
+++ b/.ci/jenkins/Jenkinsfile.setup-branch
@@ -163,18 +163,3 @@ MavenCommand getMavenCommand() {
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())
- }
-}
\ No newline at end of file
diff --git a/.ci/jenkins/project/Jenkinsfile.nightly
b/.ci/jenkins/project/Jenkinsfile.nightly
index 4bff385f28..0339dc30b0 100644
--- a/.ci/jenkins/project/Jenkinsfile.nightly
+++ b/.ci/jenkins/project/Jenkinsfile.nightly
@@ -217,7 +217,7 @@ void checkoutNewBranch(String repo, String originBranch,
String newBranch, Strin
dir(dirName) {
deleteDir()
checkout(githubscm.resolveRepository(repo, getGitAuthor(),
originBranch, false, getGitAuthorCredsId()))
- sh "git checkout -b ${newBranch}"
+ githubscm.createBranch(newBranch)
}
}
diff --git a/.ci/jenkins/project/Jenkinsfile.post-release
b/.ci/jenkins/project/Jenkinsfile.post-release
index 927e0d999e..561414a9fe 100644
--- a/.ci/jenkins/project/Jenkinsfile.post-release
+++ b/.ci/jenkins/project/Jenkinsfile.post-release
@@ -143,7 +143,7 @@ pipeline {
// }
// dir(websiteRepository) {
// checkoutRepo(websiteRepository, 'main')
- // mergeAndPush(prLink, 'main')
+ // approveAndMergePR(prLink)
// githubscm.removeRemoteBranch('origin',
prBranchName, getGitAuthorPushCredsId())
// }
// }
@@ -228,10 +228,10 @@ void checkoutTag(String repo, String tagName, String
localBranchName = tagName)
sh "git checkout tags/${tagName} -b ${localBranchName}"
}
-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]