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#767: set user config for git #3045

Merged
merged 1 commit into from
Dec 14, 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
2 changes: 1 addition & 1 deletion .ci/jenkins/Jenkinsfile.deploy
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ void commitAndCreatePR(String folder, String repo, String buildBranch) {
} else {
prBody += '\nPlease review and merge.'
}

githubscm.setUserConfigFromCreds(getGitAuthorPushCredsId())
githubscm.commitChanges(commitMsg, {
githubscm.findAndStageNotIgnoredFiles('pom.xml')
githubscm.findAndStageNotIgnoredFiles('build.gradle')
Expand Down
3 changes: 2 additions & 1 deletion .ci/jenkins/Jenkinsfile.setup-branch
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pipeline {
dir(getRepoName()) {
if (githubscm.isThereAnyChanges()) {
def commitMsg = "Update version to ${getOptaPlannerVersion()}"

githubscm.setUserConfigFromCreds(getGitAuthorPushCredsId())
githubscm.commitChanges(commitMsg, {
githubscm.findAndStageNotIgnoredFiles('pom.xml')
githubscm.findAndStageNotIgnoredFiles('antora.yml')
Expand Down Expand Up @@ -147,6 +147,7 @@ boolean isMainBranch() {

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())
Expand Down
5 changes: 3 additions & 2 deletions .ci/jenkins/project/Jenkinsfile.post-release
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,14 @@ void mergeAndPush(String prLink, String targetBranch) {

String commitAndCreatePR(String commitMsg, Closure precommit, String localBranch, String targetBranch) {
def prBody = "Generated by build ${BUILD_TAG}: ${BUILD_URL}"

githubscm.setUserConfigFromCreds(getGitAuthorPushCredsId())
githubscm.commitChanges(commitMsg, precommit)
githubscm.pushObject('origin', localBranch, getGitAuthorPushCredsId())
return githubscm.createPR(commitMsg, prBody, targetBranch, getGitAuthorCredsId())
}

void commitAndForcePushBranch(String repo, String branch) {
githubscm.setUserConfigFromCreds(getGitAuthorPushCredsId())
githubscm.commitChanges("[${getBuildBranch()}] Update ${branch} to ${getProjectVersion()}", {
githubscm.findAndStageNotIgnoredFiles('pom.xml')
githubscm.findAndStageNotIgnoredFiles('build.gradle')
Expand Down Expand Up @@ -272,7 +273,7 @@ void removeJbossNexusFromMavenAndGradle() {
}

def forcePushBranch(String branch) {
withCredentials([usernamePassword(credentialsId: getGitAuthorCredsId(), usernameVariable: 'GIT_USERNAME', passwordVariable: 'GIT_PASSWORD')]) {
withCredentials([usernamePassword(credentialsId: getGitAuthorPushCredsId(), usernameVariable: 'GIT_USERNAME', passwordVariable: 'GIT_PASSWORD')]) {
// Please leave the double-quote here. They are mandatory for the shell command to work correctly.
sh """
git config --local credential.helper \"!f() { echo username=\\$GIT_USERNAME; echo password=\\$GIT_PASSWORD; }; f\"
Expand Down