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#727: define push GH tokens for jenkins #275

Merged
merged 1 commit into from
Dec 1, 2023
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
12 changes: 10 additions & 2 deletions .ci/jenkins/Jenkinsfile.branch
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pipeline {
steps {
dir("${WORKSPACE}/${benchmarksRepo}") {
script {
githubscm.pushObject('origin', NEW_BRANCH)
githubscm.pushObject('origin', NEW_BRANCH, getGitAuthorPushCredsId())
}
}
}
Expand All @@ -62,6 +62,14 @@ pipeline {

void checkoutKieBenchmarksRepo() {
dir(benchmarksRepo) {
checkout(githubscm.resolveRepository(benchmarksRepo, GIT_AUTHOR, TARGET_BRANCH, false))
checkout(githubscm.resolveRepository(benchmarksRepo, GIT_AUTHOR, TARGET_BRANCH, false, getGitAuthorCredsId()))
}
}

String getGitAuthorCredsId() {
return env.GIT_AUTHOR_CREDS_ID
}

String getGitAuthorPushCredsId() {
return env.GIT_AUTHOR_PUSH_CREDS_ID
}
15 changes: 10 additions & 5 deletions .ci/jenkins/Jenkinsfile.bump-up-version
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pipeline {
String prLink = commitAndCreatePR(commitMsg, localBranch, "${getTargetBranch()}")
sh "git checkout ${getTargetBranch()}"
mergeAndPush(prLink, "${getTargetBranch()}")
githubscm.removeRemoteBranch('origin', localBranch, getGitAuthorCredsId())
githubscm.removeRemoteBranch('origin', localBranch, getGitAuthorPushCredsId())
}
}
}
Expand All @@ -73,7 +73,11 @@ String getGitAuthor() {
}

String getGitAuthorCredsId() {
return env.AUTHOR_CREDS_ID
return env.GIT_AUTHOR_CREDS_ID
}

String getGitAuthorPushCredsId() {
return env.GIT_AUTHOR_PUSH_CREDS_ID
}

String getTargetBranch() {
Expand All @@ -89,13 +93,14 @@ void checkoutRepo(String repository, String branch) {
String commitAndCreatePR(String commitMsg, String localBranch, String targetBranch) {
def prBody = "Generated by build ${BUILD_TAG}: ${BUILD_URL}"
githubscm.commitChanges(commitMsg)
githubscm.pushObject('origin', localBranch, getGitAuthorCredsId())
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, getGitAuthorCredsId())
githubscm.pushObject('origin', targetBranch, getGitAuthorPushCredsId())
}
}
}

3 changes: 2 additions & 1 deletion .ci/jenkins/dsl/jobs.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ void setupUpdateDependencyJob(String updateRepoName) {
UPDATE_REPO_NAME: "${updateRepoName}",

GIT_AUTHOR: "${GIT_AUTHOR_NAME}",
AUTHOR_CREDS_ID: "${GIT_AUTHOR_CREDENTIALS_ID}",
GIT_AUTHOR_CREDS_ID: "${GIT_AUTHOR_CREDENTIALS_ID}",
GIT_AUTHOR_PUSH_CREDS_ID: "${GIT_AUTHOR_PUSH_CREDENTIALS_ID}",
])
KogitoJobTemplate.createPipelineJob(this, jobParams)?.with {
parameters {
Expand Down
Loading