Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kie-issues#776: automate PR merge into protected branches #5927

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .ci/jenkins/Jenkinsfile.promote
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ pipeline {
steps {
script {
dir(getRepoName()) {
approveAndMergePR(getDeployPrLink())
checkoutRepo()
mergeAndPush(getDeployPrLink())
tagLatest()
}
}
Expand All @@ -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())
}
}
}
Expand Down Expand Up @@ -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())
}
}

Expand Down
15 changes: 0 additions & 15 deletions .ci/jenkins/Jenkinsfile.setup-branch
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
12 changes: 5 additions & 7 deletions .ci/jenkins/project/Jenkinsfile.post-release
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down Expand Up @@ -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())
}
}

Expand Down
Loading