Skip to content

Commit

Permalink
kie-issues#767: set user config for git
Browse files Browse the repository at this point in the history
  • Loading branch information
jstastny-cz committed Dec 14, 2023
1 parent 078ceea commit 85a9bfd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
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

0 comments on commit 85a9bfd

Please sign in to comment.