From 85a9bfd958e3ab4722b45fb7dc91710c83cea12a Mon Sep 17 00:00:00 2001 From: jstastny-cz Date: Thu, 14 Dec 2023 11:42:14 +0100 Subject: [PATCH] kie-issues#767: set user config for git --- .ci/jenkins/Jenkinsfile.deploy | 2 +- .ci/jenkins/Jenkinsfile.setup-branch | 3 ++- .ci/jenkins/project/Jenkinsfile.post-release | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.ci/jenkins/Jenkinsfile.deploy b/.ci/jenkins/Jenkinsfile.deploy index c7a708b7e9..68836264ac 100644 --- a/.ci/jenkins/Jenkinsfile.deploy +++ b/.ci/jenkins/Jenkinsfile.deploy @@ -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') diff --git a/.ci/jenkins/Jenkinsfile.setup-branch b/.ci/jenkins/Jenkinsfile.setup-branch index f23de513a8..bf22254755 100644 --- a/.ci/jenkins/Jenkinsfile.setup-branch +++ b/.ci/jenkins/Jenkinsfile.setup-branch @@ -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') @@ -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()) diff --git a/.ci/jenkins/project/Jenkinsfile.post-release b/.ci/jenkins/project/Jenkinsfile.post-release index 77363329dc..01cb7e4caf 100644 --- a/.ci/jenkins/project/Jenkinsfile.post-release +++ b/.ci/jenkins/project/Jenkinsfile.post-release @@ -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') @@ -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\"