This is an automated email from the ASF dual-hosted git repository.
jstastnycz pushed a commit to branch main
in repository
https://gitbox.apache.org/repos/asf/incubator-kie-kogito-pipelines.git
The following commit(s) were added to refs/heads/main by this push:
new ab1316a8 kie-issues#764: fix push for root jobs (#1145)
ab1316a8 is described below
commit ab1316a82fb1a694c0706b525cc0f3acb31ec8dd
Author: Jan Stastny <[email protected]>
AuthorDate: Thu Dec 14 08:32:57 2023 +0100
kie-issues#764: fix push for root jobs (#1145)
Co-authored-by: jstastny-cz <[email protected]>
---
dsl/seed/jenkinsfiles/Jenkinsfile.release.prepare | 10 ++++++----
dsl/seed/jenkinsfiles/Jenkinsfile.seed.main | 2 ++
dsl/seed/jobs/root_jobs.groovy | 2 ++
dsl/seed/src/main/groovy/org/kie/jenkins/jobdsl/Utils.groovy | 4 ++++
4 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/dsl/seed/jenkinsfiles/Jenkinsfile.release.prepare
b/dsl/seed/jenkinsfiles/Jenkinsfile.release.prepare
index 30531f66..58505399 100644
--- a/dsl/seed/jenkinsfiles/Jenkinsfile.release.prepare
+++ b/dsl/seed/jenkinsfiles/Jenkinsfile.release.prepare
@@ -49,7 +49,7 @@ pipeline {
def repositories = getRepositoriesToBranch()
dir(checkoutMainBranchSeedConfigFileRepo()) {
- getOrCreateGitBranch(newBranch,
getMainBranchConfigFileGitAuthorCredentialsId())
+ getOrCreateGitBranch(newBranch,
getMainBranchConfigFileGitAuthorPushCredentialsId())
// Update branch config
def branchConfig = readYaml file: branchConfigFile
@@ -87,7 +87,7 @@ pipeline {
script {
// Create seed branch if not already exist
dir(checkoutSeedRepo()) {
- getOrCreateGitBranch(getSeedRepoReleaseBranch(),
"${SEED_CREDENTIALS_ID}")
+ getOrCreateGitBranch(getSeedRepoReleaseBranch(),
"${SEED_PUSH_CREDENTIALS_ID}")
}
}
}
@@ -257,14 +257,16 @@ void createBranches(List repositories) {
String repoName = repoConfig.name
String baseBranch = repoConfig.branch
String releaseBranch = getReleaseBranchFromRepository(repoConfig.name)
+ String gitAuthorCredsId = repoConfig.author?.credentials_id ?:
readMainBranchConfig().git.author.credentials_id
+ assert gitAuthorCredsId : "Cannot find any credentials Id for git
author ${repoConfig.author.name}. Please check your branch seed config file."
String gitAuthorPushCredsId = repoConfig.author?.push?.credentials_id
?: readMainBranchConfig().git.author.push.credentials_id
- assert gitAuthorPushCredsId : "Cannot find any credentials Id for git
author ${repoConfig.author.name}. Please check your branch seed config file."
+ assert gitAuthorPushCredsId : "Cannot find any push credentials Id for
git author ${repoConfig.author.name}. Please check your branch seed config
file."
String gitAuthor = repoConfig.author?.name ?:
readMainBranchConfig().git.author.name
echo "Checkout repo ${gitAuthor}/${repoName} on branch ${baseBranch}"
dir(repoName) {
deleteDir()
- checkout(githubscm.resolveRepository(repoName, gitAuthor,
baseBranch, false, gitAuthorPushCredsId))
+ checkout(githubscm.resolveRepository(repoName, gitAuthor,
baseBranch, false, gitAuthorCredsId))
getOrCreateGitBranch(releaseBranch, gitAuthorPushCredsId)
}
// Update the branch with the new release branch
diff --git a/dsl/seed/jenkinsfiles/Jenkinsfile.seed.main
b/dsl/seed/jenkinsfiles/Jenkinsfile.seed.main
index 6d9c16e2..67a470b4 100644
--- a/dsl/seed/jenkinsfiles/Jenkinsfile.seed.main
+++ b/dsl/seed/jenkinsfiles/Jenkinsfile.seed.main
@@ -50,6 +50,7 @@ pipeline {
SEED_REPO: "${SEED_REPO}",
SEED_AUTHOR: "${SEED_AUTHOR}",
SEED_AUTHOR_CREDS_ID: "${SEED_AUTHOR_CREDS_ID}",
+ SEED_AUTHOR_PUSH_CREDS_ID:
readSeedConfig().seed.config_file.git.author.push.credentials_id, // temporary
until extra entry in all configs
SEED_BRANCH: "${SEED_BRANCH}",
SEED_CONFIG_FILE_GIT_REPOSITORY:
"${SEED_CONFIG_FILE_GIT_REPOSITORY}",
SEED_CONFIG_FILE_GIT_AUTHOR_NAME:
"${SEED_CONFIG_FILE_GIT_AUTHOR_NAME}",
@@ -94,6 +95,7 @@ pipeline {
SEED_REPO: "${SEED_REPO}",
SEED_AUTHOR: "${SEED_AUTHOR}",
SEED_AUTHOR_CREDS_ID: "${SEED_AUTHOR_CREDS_ID}",
+ SEED_AUTHOR_PUSH_CREDS_ID:
branchConfigFileInfo.push_credentials,
SEED_BRANCH: branchInfo.seed?.branch ?:
"${SEED_BRANCH}",
SEED_JENKINSFILE: branchConfigFileInfo.jenkinsfile,
SEED_CONFIG_FILE_GIT_REPOSITORY:
branchConfigFileInfo.repository,
diff --git a/dsl/seed/jobs/root_jobs.groovy b/dsl/seed/jobs/root_jobs.groovy
index 3dabe6f4..8d7db528 100644
--- a/dsl/seed/jobs/root_jobs.groovy
+++ b/dsl/seed/jobs/root_jobs.groovy
@@ -65,6 +65,7 @@ KogitoJobTemplate.createPipelineJob(this, jobParams)?.with {
env('SEED_AUTHOR', Utils.getSeedAuthor(this))
env('SEED_BRANCH', Utils.getSeedBranch(this))
env('SEED_CREDENTIALS_ID', Utils.getSeedAuthorCredsId(this))
+ env('SEED_PUSH_CREDENTIALS_ID', Utils.getSeedAuthorPushCredsId(this))
}
}
@@ -96,6 +97,7 @@ if (nonMainBranches) {
env('GIT_REPOSITORY', "${SEED_CONFIG_FILE_GIT_REPOSITORY}")
env('GIT_AUTHOR', "${SEED_CONFIG_FILE_GIT_AUTHOR_NAME}")
env('GIT_AUTHOR_CREDENTIALS_ID',
"${SEED_CONFIG_FILE_GIT_AUTHOR_CREDS_ID}")
+ env('GIT_AUTHOR_PUSH_CREDENTIALS_ID',
"${SEED_CONFIG_FILE_GIT_AUTHOR_PUSH_CREDS_ID}")
env('GIT_BRANCH_TO_BUILD', "${SEED_CONFIG_FILE_GIT_BRANCH}")
env('CONFIG_FILE_PATH', "${SEED_CONFIG_FILE_PATH}")
}
diff --git a/dsl/seed/src/main/groovy/org/kie/jenkins/jobdsl/Utils.groovy
b/dsl/seed/src/main/groovy/org/kie/jenkins/jobdsl/Utils.groovy
index 0e3b3adf..90212bf6 100644
--- a/dsl/seed/src/main/groovy/org/kie/jenkins/jobdsl/Utils.groovy
+++ b/dsl/seed/src/main/groovy/org/kie/jenkins/jobdsl/Utils.groovy
@@ -230,6 +230,10 @@ class Utils {
return getBindingValue(script, 'SEED_AUTHOR_CREDS_ID')
}
+ static String getSeedAuthorPushCredsId(def script) {
+ return getBindingValue(script, 'SEED_AUTHOR_PUSH_CREDS_ID')
+ }
+
static String getSeedBranch(def script) {
return getBindingValue(script, 'SEED_BRANCH')
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]