diff --git a/.ci/jenkins/Jenkinsfile.nightly b/.ci/jenkins/Jenkinsfile.nightly index e8880a1de..e8940188d 100644 --- a/.ci/jenkins/Jenkinsfile.nightly +++ b/.ci/jenkins/Jenkinsfile.nightly @@ -118,10 +118,10 @@ pipeline { // Update examples nightly branch dir('kogito-examples') { deleteDir() - checkout(githubscm.resolveRepository('incubator-kie-kogito-examples', getGitAuthor(), getBuildBranch(), false, getGitAuthorCredsID())) + checkout(githubscm.resolveRepository('incubator-kie-kogito-examples', getGitAuthor(), getBuildBranch(), false, getGitAuthorCredsId())) String nightlyBranch = "nightly-${getBuildBranch()}" githubscm.createBranch(nightlyBranch) - githubscm.pushObject('origin', nightlyBranch, getGitAuthorCredsID()) + githubscm.pushObject('origin', nightlyBranch, getGitAuthorPushCredsId()) } } } @@ -243,6 +243,10 @@ String getGitAuthor() { return env.GIT_AUTHOR } -String getGitAuthorCredsID() { +String getGitAuthorCredsId() { return env.GIT_AUTHOR_CREDS_ID } + +String getGitAuthorPushCredsId() { + return env.GIT_AUTHOR_PUSH_CREDS_ID +} diff --git a/.ci/jenkins/Jenkinsfile.nightly.cloud b/.ci/jenkins/Jenkinsfile.nightly.cloud index fc6e572ea..c8d9037ca 100644 --- a/.ci/jenkins/Jenkinsfile.nightly.cloud +++ b/.ci/jenkins/Jenkinsfile.nightly.cloud @@ -306,7 +306,7 @@ String getGitAuthor() { return env.GIT_AUTHOR } -String getGitAuthorCredsID() { +String getGitAuthorCredsId() { return env.GIT_AUTHOR_CREDS_ID } diff --git a/.ci/jenkins/Jenkinsfile.setup-branch b/.ci/jenkins/Jenkinsfile.setup-branch index 79a59f027..9fa593ffd 100644 --- a/.ci/jenkins/Jenkinsfile.setup-branch +++ b/.ci/jenkins/Jenkinsfile.setup-branch @@ -75,10 +75,10 @@ pipeline { // Update examples nightly branch dir('kogito-examples') { deleteDir() - checkout(githubscm.resolveRepository('incubator-kie-kogito-examples', getGitAuthor(), getBuildBranch(), false)) + checkout(githubscm.resolveRepository('incubator-kie-kogito-examples', getGitAuthor(), getBuildBranch(), false, getGitAuthorCredsId())) String nightlyBranch = "nightly-${getBuildBranch()}" githubscm.createBranch(nightlyBranch) - githubscm.pushObject('origin', nightlyBranch, getGitAuthorCredsID()) + githubscm.pushObject('origin', nightlyBranch, getGitAuthorPushCredsId()) } } } @@ -231,10 +231,14 @@ String getGitAuthor() { return env.GIT_AUTHOR } -String getGitAuthorCredsID() { +String getGitAuthorCredsId() { return env.GIT_AUTHOR_CREDS_ID } +String getGitAuthorPushCredsId() { + return env.GIT_AUTHOR_PUSH_CREDS_ID +} + String getDroolsVersion() { return params.DROOLS_VERSION ?: getVersionFromReleaseBranch(util.calculateTargetReleaseBranch(getBuildBranch(), 7)) } diff --git a/.ci/jenkins/Jenkinsfile.setup-branch.cloud b/.ci/jenkins/Jenkinsfile.setup-branch.cloud index f03831de0..bdbb330e3 100644 --- a/.ci/jenkins/Jenkinsfile.setup-branch.cloud +++ b/.ci/jenkins/Jenkinsfile.setup-branch.cloud @@ -191,7 +191,7 @@ String getGitAuthor() { return env.GIT_AUTHOR } -String getGitAuthorCredsID() { +String getGitAuthorCredsId() { return env.GIT_AUTHOR_CREDS_ID } diff --git a/.ci/jenkins/Jenkinsfile.tools.update-jenkins-dependencies b/.ci/jenkins/Jenkinsfile.tools.update-jenkins-dependencies index f9004c581..45d98d7d0 100644 --- a/.ci/jenkins/Jenkinsfile.tools.update-jenkins-dependencies +++ b/.ci/jenkins/Jenkinsfile.tools.update-jenkins-dependencies @@ -29,9 +29,9 @@ pipeline { deleteDir() // Checkout repository - checkout(githubscm.resolveRepository(getRepoName(), getGitAuthor(), getBuildBranch(), false, getGitAuthorCredsID())) - githubscm.setUserConfig(getGitAuthorCredsID()) - branchCreated = getOrCreateGitBranch(getPRBranch(), getGitAuthorCredsID()) + checkout(githubscm.resolveRepository(getRepoName(), getGitAuthor(), getBuildBranch(), false, getGitAuthorCredsId())) + githubscm.setUserConfig(getGitAuthorCredsId()) + branchCreated = getOrCreateGitBranch(getPRBranch(), getGitAuthorPushCredsId()) } } } @@ -127,11 +127,11 @@ pipeline { githubscm.findAndStageNotIgnoredFiles('pom.xml') githubscm.findAndStageNotIgnoredFiles('gradle.properties') }) - githubscm.pushObject('origin', getPRBranch(), getGitAuthorCredsID()) + githubscm.pushObject('origin', getPRBranch(), getGitAuthorPushCredsId()) if (branchCreated) { def prBody = "Generated by build ${BUILD_TAG}: ${BUILD_URL}.\nPlease review and merge." - prLink = githubscm.createPR(commitMsg, prBody, getBuildBranch(), getGitAuthorCredsID()) + prLink = githubscm.createPR(commitMsg, prBody, getBuildBranch(), getGitAuthorCredsId()) sendNotification("Please review PR ${prLink}") } else { @@ -185,8 +185,12 @@ String getGitAuthor() { return env.GIT_AUTHOR } -String getGitAuthorCredsID() { - return env.AUTHOR_CREDS_ID +String getGitAuthorCredsId() { + return env.GIT_AUTHOR_CREDS_ID +} + +String getGitAuthorPushCredsId() { + return env.GIT_AUTHOR_PUSH_CREDS_ID } String getPRBranch() { diff --git a/.ci/jenkins/config/branch.yaml b/.ci/jenkins/config/branch.yaml index 6ed168c9c..d2a7b6550 100644 --- a/.ci/jenkins/config/branch.yaml +++ b/.ci/jenkins/config/branch.yaml @@ -54,8 +54,6 @@ repositories: job_display_name: kogito-serverless-operator - name: incubator-kie-kogito-docs job_display_name: kogito-docs -# - name: incubator-kie-tools // Commented as this one will be treated at another time -# job_display_name: kie-tools - name: incubator-kie-docs job_display_name: kie-docs branch: main-kogito @@ -66,9 +64,14 @@ git: # Need to be verified credentials_id: 399061d0-5ab5-4142-a186-a52081fef742 token_credentials_id: ci-builds + push: + credentials_id: 84811880-2025-45b6-a44c-2f33bef30ad2 # CI Push Access for KIE + token_credentials_id: 41128c14-bb63-4708-9074-d20a318ee630 # GitHub Personal Access Token for KIE fork_author: name: kie-ci credentials_id: kie-ci + push: + credentials_id: kie-ci quarkus: author: name: quarkusio diff --git a/.ci/jenkins/config/main.yaml b/.ci/jenkins/config/main.yaml index dab62f910..449e7e72e 100644 --- a/.ci/jenkins/config/main.yaml +++ b/.ci/jenkins/config/main.yaml @@ -29,6 +29,8 @@ seed: author: name: apache credentials_id: ASF_Cloudbees_Jenkins_ci-builds + push: + credentials_id: 84811880-2025-45b6-a44c-2f33bef30ad2 # CI Push Access for KIE branch: main path: .ci/jenkins/config/branch.yaml jenkinsfile: dsl/seed/jenkinsfiles/Jenkinsfile.seed.branch diff --git a/.ci/jenkins/dsl/jobs.groovy b/.ci/jenkins/dsl/jobs.groovy index 8f177af6d..9405599e7 100644 --- a/.ci/jenkins/dsl/jobs.groovy +++ b/.ci/jenkins/dsl/jobs.groovy @@ -120,7 +120,8 @@ void setupUpdateJenkinsDependenciesJob() { BUILD_BRANCH_NAME: "${GIT_BRANCH}", 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) } @@ -133,6 +134,7 @@ void createSetupBranchJob() { GIT_BRANCH_NAME: "${GIT_BRANCH}", GIT_AUTHOR: "${GIT_AUTHOR_NAME}", GIT_AUTHOR_CREDS_ID: "${GIT_AUTHOR_CREDENTIALS_ID}", + GIT_AUTHOR_PUSH_CREDS_ID: "${GIT_AUTHOR_PUSH_CREDENTIALS_ID}", ]) KogitoJobTemplate.createPipelineJob(this, jobParams)?.with { parameters { @@ -170,6 +172,7 @@ void setupNightlyJob() { GIT_BRANCH_NAME: "${GIT_BRANCH}", GIT_AUTHOR: "${GIT_AUTHOR_NAME}", GIT_AUTHOR_CREDS_ID: "${GIT_AUTHOR_CREDENTIALS_ID}", + GIT_AUTHOR_PUSH_CREDS_ID: "${GIT_AUTHOR_PUSH_CREDENTIALS_ID}", ]) KogitoJobTemplate.createPipelineJob(this, jobParams)?.with { parameters { diff --git a/.ci/pull-request-config.yaml b/.ci/pull-request-config.yaml index f63835e8f..f188377ba 100644 --- a/.ci/pull-request-config.yaml +++ b/.ci/pull-request-config.yaml @@ -57,14 +57,16 @@ build: - project: apache/incubator-kie-kogito-examples build-command: # First install the main pom - # Then build the required submodule pom + # Then build the required submodule pom if provided, otherwise build whole current: | - export MVN_CMD=`bash -c "if [ '${{ env.ENABLE_DEPLOY }}' = 'true' ]; then printf 'deploy ${{ env.DEPLOY_MVN_OPTS }} ${{ env.KOGITO_EXAMPLES_DEPLOY_MVN_OPTS }}'; else printf 'install'; fi"` - mvn dependency:tree -pl :kogito-examples clean ${{ env.MVN_CMD }} ${{ env.BUILD_MVN_OPTS }} ${{ env.BUILD_MVN_OPTS_CURRENT }} ${{ env.KOGITO_EXAMPLES_BUILD_MVN_OPTS }} - mvn dependency:tree -f ${{ env.KOGITO_EXAMPLES_SUBFOLDER_POM }}pom.xml clean ${{ env.MVN_CMD }} ${{ env.BUILD_MVN_OPTS }} ${{ env.BUILD_MVN_OPTS_CURRENT }} ${{ env.KOGITO_EXAMPLES_BUILD_MVN_OPTS }} + mvn dependency:tree -pl :kogito-examples clean install ${{ env.BUILD_MVN_OPTS }} ${{ env.BUILD_MVN_OPTS_CURRENT }} ${{ env.KOGITO_EXAMPLES_BUILD_MVN_OPTS }} + mvn dependency:tree -f ${{ env.KOGITO_EXAMPLES_SUBFOLDER_POM }}pom.xml clean install ${{ env.BUILD_MVN_OPTS }} ${{ env.BUILD_MVN_OPTS_CURRENT }} ${{ env.KOGITO_EXAMPLES_BUILD_MVN_OPTS }} upstream: | mvn dependency:tree clean install -DskipTests -DskipITs ${{ env.BUILD_MVN_OPTS }} ${{ env.BUILD_MVN_OPTS_UPSTREAM }} ${{ env.KOGITO_EXAMPLES_BUILD_MVN_OPTS_UPSTREAM }} - + after: + # In case of deploy, deploy the parent poms only. + current: | + bash -c "if [ '${{ env.ENABLE_DEPLOY }}' = 'true' ]; then mvn dependency:tree -DskipTests -DskipITs -pl .,kogito-quarkus-examples,kogito-springboot-examples,serverless-workflow-examples deploy ${{ env.DEPLOY_MVN_OPTS }} ${{ env.KOGITO_EXAMPLES_DEPLOY_MVN_OPTS }}; else echo 'No deploy is scheduled'; fi" # - project: kiegroup/kie-jpmml-integration # build-command: # current: | diff --git a/dsl/seed/jenkinsfiles/Jenkinsfile.environment.integration-branch b/dsl/seed/jenkinsfiles/Jenkinsfile.environment.integration-branch index b766d8beb..d37af0210 100644 --- a/dsl/seed/jenkinsfiles/Jenkinsfile.environment.integration-branch +++ b/dsl/seed/jenkinsfiles/Jenkinsfile.environment.integration-branch @@ -99,7 +99,7 @@ String getGitAuthor() { } String getGitAuthorCredsId() { - return "${AUTHOR_CREDS_ID}" + return "${GIT_AUTHOR_CREDS_ID}" } String getGitAuthorTokenCredsId() { diff --git a/dsl/seed/jenkinsfiles/Jenkinsfile.release.prepare b/dsl/seed/jenkinsfiles/Jenkinsfile.release.prepare index 10bcf835b..30531f669 100644 --- a/dsl/seed/jenkinsfiles/Jenkinsfile.release.prepare +++ b/dsl/seed/jenkinsfiles/Jenkinsfile.release.prepare @@ -71,7 +71,7 @@ pipeline { if (githubscm.isThereAnyChanges()) { sh 'git diff' githubscm.commitChanges('Setup DSL branch config after cut-off') - githubscm.pushObject('origin', newBranch, getMainBranchConfigFileGitAuthorCredentialsId()) + githubscm.pushObject('origin', newBranch, getMainBranchConfigFileGitAuthorPushCredentialsId()) sendNotification("Branch config on ${newBranch} has been updated with correct configuration") } else { @@ -126,7 +126,7 @@ pipeline { if (githubscm.isThereAnyChanges()) { sh 'git diff' githubscm.commitChanges("Add release branch ${getEcosystemReleaseBranch()} after cut-off") - githubscm.pushObject('origin', env.SEED_CONFIG_FILE_GIT_BRANCH, env.SEED_CONFIG_FILE_GIT_AUTHOR_CREDS_ID) + githubscm.pushObject('origin', env.SEED_CONFIG_FILE_GIT_BRANCH, env.SEED_CONFIG_FILE_GIT_AUTHOR_PUSH_CREDS_ID) sendNotification("Main config has been updated with release branch ${getEcosystemReleaseBranch()}") } else { @@ -257,15 +257,15 @@ 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." 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, gitAuthorCredsId)) - getOrCreateGitBranch(releaseBranch, gitAuthorCredsId) + checkout(githubscm.resolveRepository(repoName, gitAuthor, baseBranch, false, gitAuthorPushCredsId)) + getOrCreateGitBranch(releaseBranch, gitAuthorPushCredsId) } // Update the branch with the new release branch repoConfig.branch = releaseBranch @@ -403,6 +403,10 @@ String getMainBranchConfigFileGitAuthorCredentialsId() { return readSeedConfig().seed.config_file.git.author.credentials_id } +String getMainBranchConfigFileGitAuthorPushCredentialsId() { + return readSeedConfig().seed.config_file.git.author.push.credentials_id +} + String getMainBranchConfigFileGitBranch() { return readSeedConfig().seed.config_file.git.branch } diff --git a/dsl/seed/jenkinsfiles/Jenkinsfile.remove.branches b/dsl/seed/jenkinsfiles/Jenkinsfile.remove.branches index ffedc9295..a9e64b0f5 100644 --- a/dsl/seed/jenkinsfiles/Jenkinsfile.remove.branches +++ b/dsl/seed/jenkinsfiles/Jenkinsfile.remove.branches @@ -72,7 +72,7 @@ pipeline { String prLink = commitAndCreatePR(commitMsg, localBranch, targetBranch) sh "git checkout ${targetBranch}" mergeAndPush(prLink, targetBranch) - githubscm.removeRemoteBranch('origin', localBranch, getGitAuthorCredsId()) + githubscm.removeRemoteBranch('origin', localBranch, getGitAuthorPushCredsId()) } else { println '[WARN] no changes to commit' } @@ -114,6 +114,10 @@ void getGitAuthorCredsId(){ return env.GIT_AUTHOR_CREDENTIALS_ID } +void getGitAuthorPushCredsId(){ + return env.GIT_AUTHOR_PUSH_CREDENTIALS_ID +} + void getGitAuthor() { return env.GIT_AUTHOR } @@ -131,13 +135,13 @@ void sendErrorNotification() { String commitAndCreatePR(String commitMsg, String localBranch, String targetBranch) { def prBody = "Generated by ${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()) } } diff --git a/dsl/seed/jenkinsfiles/Jenkinsfile.seed.branch b/dsl/seed/jenkinsfiles/Jenkinsfile.seed.branch index b1e8fa295..4a06492b5 100644 --- a/dsl/seed/jenkinsfiles/Jenkinsfile.seed.branch +++ b/dsl/seed/jenkinsfiles/Jenkinsfile.seed.branch @@ -135,6 +135,7 @@ pipeline { (generateEnvKey(it, 'git_branch')): getRepoConfig(it).git.branch, (generateEnvKey(it, 'git_author')): getRepoConfig(it).git.author.name, (generateEnvKey(it, 'git_author_credentials_id')): getRepoConfig(it).git.author.credentials_id, + (generateEnvKey(it, 'git_author_push_credentials_id')): getRepoConfig(it).git.author.push.credentials_id, ] } @@ -269,7 +270,9 @@ def getRepoConfig(String repository, String generationBranch = "${GENERATION_BRA cfg.git.author = cfg.git.author ?: [:] cfg.git.author.name = repoConfig.author?.name ?: cfg.git.author.name cfg.git.author.credentials_id = repoConfig.author?.credentials_id ?: cfg.git.author.credentials_id + cfg.git.author.push.credentials_id = repoConfig.author?.push?.credentials_id ?: cfg.git.author.push.credentials_id cfg.git.author.token_credentials_id = repoConfig.author?.credentials_id ?: cfg.git.author.token_credentials_id + cfg.git.author.push.token_credentials_id = repoConfig.author?.push?.token_credentials_id ?: cfg.git.author.push.token_credentials_id String buildchainRepo = cfg.buildchain_config?.git?.repository if (buildchainRepo) { diff --git a/dsl/seed/jenkinsfiles/Jenkinsfile.seed.main b/dsl/seed/jenkinsfiles/Jenkinsfile.seed.main index 30af77194..6d9c16e2e 100644 --- a/dsl/seed/jenkinsfiles/Jenkinsfile.seed.main +++ b/dsl/seed/jenkinsfiles/Jenkinsfile.seed.main @@ -54,6 +54,7 @@ pipeline { SEED_CONFIG_FILE_GIT_REPOSITORY: "${SEED_CONFIG_FILE_GIT_REPOSITORY}", SEED_CONFIG_FILE_GIT_AUTHOR_NAME: "${SEED_CONFIG_FILE_GIT_AUTHOR_NAME}", SEED_CONFIG_FILE_GIT_AUTHOR_CREDS_ID: "${SEED_CONFIG_FILE_GIT_AUTHOR_CREDS_ID}", + SEED_CONFIG_FILE_GIT_AUTHOR_PUSH_CREDS_ID: readSeedConfig().seed.config_file.git.author.push.credentials_id, SEED_CONFIG_FILE_GIT_BRANCH: "${SEED_CONFIG_FILE_GIT_BRANCH}", SEED_CONFIG_FILE_PATH: "${SEED_CONFIG_FILE_PATH}", ALL_BRANCHES: readSeedConfig().git.branches.collect { it.name }.join(','), @@ -98,6 +99,7 @@ pipeline { SEED_CONFIG_FILE_GIT_REPOSITORY: branchConfigFileInfo.repository, SEED_CONFIG_FILE_GIT_AUTHOR_NAME: branchConfigFileInfo.author, SEED_CONFIG_FILE_GIT_AUTHOR_CREDS_ID: branchConfigFileInfo.credentials, + SEED_CONFIG_FILE_GIT_AUTHOR_PUSH_CREDS_ID: branchConfigFileInfo.push_credentials, SEED_CONFIG_FILE_GIT_BRANCH: branchConfigFileInfo.branch, SEED_CONFIG_FILE_PATH: branchConfigFileInfo.filepath, ] @@ -226,6 +228,7 @@ def getBranchConfigFileInfo(branchInfo) { repository: branchInfo.seed?.config_file?.git?.repository ?: readSeedConfig().seed.config_file.git.repository, author: branchInfo.seed?.config_file?.git?.author?.name ?: readSeedConfig().seed.config_file.git.author.name, credentials: branchInfo.seed?.config_file?.git?.author?.credentials_id ?: readSeedConfig().seed.config_file.git.author.credentials_id, + push_credentials: branchInfo.seed?.config_file?.git?.author?.push?.credentials_id ?: readSeedConfig().seed.config_file.git.author.push.credentials_id, branch: branchInfo.seed?.config_file?.git?.branch ?: branchInfo.name, filepath: branchInfo.seed?.config_file?.path ?: readSeedConfig().seed.config_file.path, jenkinsfile: branchInfo.seed?.jenkinsfile ?: (readSeedConfig().seed.jenkinsfile ?: 'dsl/seed/jenkinsfiles/Jenkinsfile.seed.branch'), diff --git a/dsl/seed/jenkinsfiles/Jenkinsfile.tools.toggle-triggers b/dsl/seed/jenkinsfiles/Jenkinsfile.tools.toggle-triggers index 1e60b137c..43793636f 100644 --- a/dsl/seed/jenkinsfiles/Jenkinsfile.tools.toggle-triggers +++ b/dsl/seed/jenkinsfiles/Jenkinsfile.tools.toggle-triggers @@ -56,7 +56,7 @@ pipeline { String commitMsg = "[${getSeedConfigBranch()}] DSL triggers ${DISABLE_TRIGGERS ? 'disabled' : 'enabled'}" githubscm.createBranch(getPRBranch()) githubscm.commitChanges(commitMsg) - githubscm.pushObject('origin', getPRBranch(), getSeedConfigAuthorCredsId()) + githubscm.pushObject('origin', getPRBranch(), getSeedConfigAuthorPushCredsId()) // Create PR def prBody = "Generated by ${BUILD_URL}" @@ -65,8 +65,8 @@ pipeline { // Merge automatically PR sh "git checkout ${getSeedConfigBranch()}" githubscm.mergePR(prLink, getSeedConfigAuthorCredsId()) - githubscm.pushObject('origin', getSeedConfigBranch(), getSeedConfigAuthorCredsId()) - githubscm.removeRemoteBranch('origin', getPRBranch(), SEED_CONFIG_FILE_GIT_AUTHOR_CREDS_ID) + githubscm.pushObject('origin', getSeedConfigBranch(), getSeedConfigAuthorPushCredsId()) + githubscm.removeRemoteBranch('origin', getPRBranch(), getSeedConfigAuthorPushCredsId()) } else { println '[WARN] no changes to commit' } @@ -103,6 +103,10 @@ String getSeedConfigAuthorCredsId() { return env.SEED_CONFIG_FILE_GIT_AUTHOR_CREDS_ID } +String getSeedConfigAuthorPushCredsId() { + return env.SEED_CONFIG_FILE_GIT_AUTHOR_PUSH_CREDS_ID +} + String getSeedConfigBranch() { return env.SEED_CONFIG_FILE_GIT_BRANCH } diff --git a/dsl/seed/jenkinsfiles/Jenkinsfile.update-dependency-version b/dsl/seed/jenkinsfiles/Jenkinsfile.update-dependency-version index 969fd622a..2e9def853 100644 --- a/dsl/seed/jenkinsfiles/Jenkinsfile.update-dependency-version +++ b/dsl/seed/jenkinsfiles/Jenkinsfile.update-dependency-version @@ -42,7 +42,7 @@ pipeline { steps { script { dir(getRepoName()) { - branchCreated = getOrCreateGitBranch(getPRBranch(), getGitAuthorCredsId()) + branchCreated = getOrCreateGitBranch(getPRBranch(), getGitAuthorPushCredsId()) } } } @@ -142,7 +142,7 @@ pipeline { if (githubscm.isThereAnyChanges()) { String commitMsg = "[${getBuildBranch()}] ${getJiraNumber() ? "[${getJiraNumber()}] " : ''}Bump ${getDependencyName()} version to ${getNewVersion()}" githubscm.commitChanges(commitMsg) - githubscm.pushObject('origin', getPRBranch(), getGitAuthorCredsId()) + githubscm.pushObject('origin', getPRBranch(), getGitAuthorPushCredsId()) if (branchCreated) { String prLink = githubscm.createPR(commitMsg, 'Please review and merge', getBuildBranch(), getGitAuthorCredsId()) @@ -186,7 +186,11 @@ String getGitAuthor() { } String getGitAuthorCredsId() { - return "${AUTHOR_CREDS_ID}" + return "${GIT_AUTHOR_CREDS_ID}" +} + +String getGitAuthorPushCredsId() { + return "${GIT_AUTHOR_PUSH_CREDS_ID}" } String getPRBranch() { diff --git a/dsl/seed/jenkinsfiles/Jenkinsfile.update-quarkus-platform b/dsl/seed/jenkinsfiles/Jenkinsfile.update-quarkus-platform index 967838b08..575399930 100644 --- a/dsl/seed/jenkinsfiles/Jenkinsfile.update-quarkus-platform +++ b/dsl/seed/jenkinsfiles/Jenkinsfile.update-quarkus-platform @@ -38,7 +38,7 @@ pipeline { dir(quarkusPlatformRepo){ checkoutRepo(quarkusPlatformRepo, getQuarkusPlatformAuthor(), getQuarkusPlatformBranch(), getQuarkusPlatformAuthorCredsId()) - githubscm.forkRepo("${FORK_GIT_AUTHOR_CREDS_ID}") + githubscm.forkRepo("${getGitForkAuthorPushCredsId()}") } } } @@ -53,10 +53,10 @@ pipeline { String commitMsg = getCommitMessage() String localBranch = getLocalBranchName() dir(quarkusPlatformRepo){ - branchCreated = getOrCreateGitBranch(localBranch, "${FORK_GIT_AUTHOR_CREDS_ID}") + branchCreated = getOrCreateGitBranch(localBranch, "${getGitForkAuthorPushCredsId()}") // run update-quarkus-platform.sh with 'stage' - sh "${WORKSPACE}/tools/update-quarkus-platform.sh -p ${getProjectName()} -s -v ${getNewVersion()} -f ${FORK_GIT_AUTHOR} -h ${localBranch} -n -r ${getCommand()}" + sh "${WORKSPACE}/tools/update-quarkus-platform.sh -p ${getProjectName()} -s -v ${getNewVersion()} -f ${getGitForkAuthor()} -h ${localBranch} -n -r ${getCommand()}" sh "git status" @@ -65,9 +65,9 @@ pipeline { if (githubscm.isThereAnyChanges()) { githubscm.commitChanges(commitMsg, { sh "git add --all" }) - githubscm.pushObject('origin', localBranch, "${FORK_GIT_AUTHOR_CREDS_ID}") + githubscm.pushObject('origin', localBranch, "${getGitForkAuthorPushCredsId()}") if (branchCreated) { - prLink = githubscm.createPrAsDraft(commitMsg, prBody, getQuarkusPlatformBranch(), "${FORK_GIT_AUTHOR_CREDS_ID}") + prLink = githubscm.createPrAsDraft(commitMsg, prBody, getQuarkusPlatformBranch(), "${getGitForkAuthorCredsId()}") sendNotification("Draft PR was created with ${getProjectName()} to version ${getNewVersion()}.\nHere is the PR link: ${prLink}") } else { echo "Branch ${localBranch} was already created so assuming the PR exists alrerady ..." @@ -93,11 +93,11 @@ pipeline { sh "git checkout ${localBranch}" // run update-quarkus-platform.sh with 'finalize' - sh "${WORKSPACE}/tools/update-quarkus-platform.sh -p ${getProjectName()} -s -d -v ${getNewVersion()} -f ${FORK_GIT_AUTHOR} -h ${localBranch} -n -r ${getCommand()}" + sh "${WORKSPACE}/tools/update-quarkus-platform.sh -p ${getProjectName()} -s -d -v ${getNewVersion()} -f ${getGitForkAuthor()} -h ${localBranch} -n -r ${getCommand()}" githubscm.squashCommits(getQuarkusPlatformBranch(), commitMsg) - githubscm.pushObject('--force-with-lease origin', localBranch, "${FORK_GIT_AUTHOR_CREDS_ID}") + githubscm.pushObject('--force-with-lease origin', localBranch, "${getGitForkAuthorPushCredsId()}") sendNotification("PR was finalized with ${getProjectName()} to version ${getNewVersion()}.") } } @@ -111,13 +111,6 @@ pipeline { } } -String commitAndCreatePR(String commitMsg, Closure precommit, String localBranch, String targetBranch) { - def prBody = "Generated by build ${BUILD_TAG}: ${BUILD_URL}" - githubscm.commitChanges(commitMsg, precommit) - githubscm.pushObject('origin', localBranch) - return githubscm.createPrAsDraft(commitMsg, prBody, targetBranch) -} - /** * Return true if the branch was created */ @@ -176,22 +169,26 @@ String getBuildBranch() { return env.BUILD_BRANCH_NAME } -String getGitAuthor() { - return env.GIT_AUTHOR +String getGitForkAuthor() { + return env.GIT_FORK_AUTHOR +} + +String getGitForkAuthorCredsId() { + return env.GIT_FORK_AUTHOR_CREDS_ID } -String getGitAuthorCredsId() { - return env.GIT_AUTHOR_CREDENTIALS_ID +String getGitForkAuthorPushCredsId() { + return env.GIT_FORK_AUTHOR_PUSH_CREDS_ID } String getQuarkusPlatformBranch() { - return params.QUARKUS_PLATFORM_BRANCH + return params.GIT_QUARKUS_BRANCH } String getQuarkusPlatformAuthor() { - return env.QUARKUS_PLATFORM_AUTHOR_NAME + return env.GIT_QUARKUS_AUTHOR_NAME } String getQuarkusPlatformAuthorCredsId() { - return env.QUARKUS_PLATFORM_AUTHOR_CREDENTIALS_ID + return env.GIT_QUARKUS_AUTHOR_CREDENTIALS_ID } diff --git a/dsl/seed/jenkinsfiles/Jenkinsfile.update-quarkus-version b/dsl/seed/jenkinsfiles/Jenkinsfile.update-quarkus-version index d1c28fcf8..61848fe9c 100644 --- a/dsl/seed/jenkinsfiles/Jenkinsfile.update-quarkus-version +++ b/dsl/seed/jenkinsfiles/Jenkinsfile.update-quarkus-version @@ -28,25 +28,25 @@ pipeline { stage('Update quarkus version in branch config') { steps { script { - String prBranch = getSeedPRBranch("${SEED_BRANCH_CONFIG_FILE_GIT_BRANCH}") - dir("${SEED_BRANCH_CONFIG_FILE_GIT_REPOSITORY}") { + String prBranch = getSeedPRBranch("${getSeedConfigFileGitBranch()}") + dir("${getSeedConfigFileGitRepository()}") { deleteDir() - checkout(githubscm.resolveRepository("${SEED_BRANCH_CONFIG_FILE_GIT_REPOSITORY}", "${SEED_BRANCH_CONFIG_FILE_GIT_AUTHOR_NAME}", "${SEED_BRANCH_CONFIG_FILE_GIT_BRANCH}", false, "${SEED_BRANCH_CONFIG_FILE_GIT_AUTHOR_CREDS_ID}")) + checkout(githubscm.resolveRepository("${getSeedConfigFileGitRepository()}", "${getSeedConfigFileGitAuthor()}", "${getSeedConfigFileGitBranch()}", false, "${getSeedConfigFileGitAuthorCredsId()}")) - getOrCreateGitBranch(prBranch, "${SEED_BRANCH_CONFIG_FILE_GIT_AUTHOR_CREDS_ID}") + getOrCreateGitBranch(prBranch, "${getSeedConfigFileGitAuthorPushCredsId()}") - updateYaml("${SEED_BRANCH_CONFIG_FILE_PATH}") { branchConfig -> + updateYaml("${getSeedConfigFilePath()}") { branchConfig -> if (branchConfig.environments?.'quarkus-branch'?.env_vars?.QUARKUS_BRANCH) { branchConfig.environments.'quarkus-branch'.env_vars.QUARKUS_BRANCH = getNewVersionBranch() } } if (githubscm.isThereAnyChanges()) { - String commitMsg = "[${SEED_BRANCH_CONFIG_FILE_GIT_BRANCH}] ${getJiraNumber() ? "[${getJiraNumber()}] " : ''}Bump quarkus version to ${getNewVersion()}" + String commitMsg = "[${getSeedConfigFileGitBranch()}] ${getJiraNumber() ? "[${getJiraNumber()}] " : ''}Bump quarkus version to ${getNewVersion()}" githubscm.commitChanges(commitMsg) - githubscm.pushObject('origin', prBranch, "${SEED_BRANCH_CONFIG_FILE_GIT_AUTHOR_CREDS_ID}") + githubscm.pushObject('origin', prBranch, "${getSeedConfigFileGitAuthorPushCredsId()}") - String prLink = githubscm.createPR(commitMsg, 'Please review and merge', "${SEED_BRANCH_CONFIG_FILE_GIT_BRANCH}", "${SEED_BRANCH_CONFIG_FILE_GIT_AUTHOR_CREDS_ID}") + String prLink = githubscm.createPR(commitMsg, 'Please review and merge', "${getSeedConfigFileGitBranch()}", "${getSeedConfigFileGitAuthorCredsId()}") echo "Created PR ${prLink}" prLinks.add(prLink) } else { @@ -172,6 +172,33 @@ def readPipelineProperties(String jobUrl) { return pipelineProperties } +String getSeedConfigFileGitRepository() { + return env.SEED_CONFIG_FILE_GIT_REPOSITORY +} +String getSeedConfigFilePath() { + return env.SEED_CONFIG_FILE_PATH +} + +String getSeedConfigFileGitAuthor() { + return env.SEED_CONFIG_FILE_GIT_AUTHOR +} + +String getSeedConfigFileGitBranch() { + return env.SEED_CONFIG_FILE_GIT_BRANCH +} + +String getSeedConfigFileGitAuthorCredsId() { + return env.SEED_CONFIG_FILE_GIT_AUTHOR_CREDS_ID +} + +String getSeedConfigFileGitAuthorPushCredsId() { + return env.SEED_CONFIG_FILE_GIT_AUTHOR_PUSH_CREDS_ID +} + +String getGitAuthorTokenCredsId() { + return env.GIT_AUTHOR_TOKEN_CREDS_ID +} + String getNewVersion() { return params.NEW_VERSION } @@ -213,7 +240,7 @@ void getOrCreateGitBranch(String branch, String credentialsId) { } void finalizePR(String prLink) { - withCredentials([string(credentialsId: "${GITHUB_TOKEN_CREDS_ID}", variable: 'GITHUB_TOKEN')]) { + withCredentials([string(credentialsId: "${getGitAuthorTokenCredsId()}", variable: 'GITHUB_TOKEN')]) { String currentBodyJson = sh(returnStdout: true, script: "gh pr view ${prLink} --json body").trim() echo "currentBodyjson = ${currentBodyJson}" String newBody = """ diff --git a/dsl/seed/jobs/root_jobs.groovy b/dsl/seed/jobs/root_jobs.groovy index 81175a8c7..3dabe6f40 100644 --- a/dsl/seed/jobs/root_jobs.groovy +++ b/dsl/seed/jobs/root_jobs.groovy @@ -57,6 +57,7 @@ KogitoJobTemplate.createPipelineJob(this, jobParams)?.with { env('SEED_CONFIG_FILE_GIT_REPOSITORY', "${SEED_CONFIG_FILE_GIT_REPOSITORY}") env('SEED_CONFIG_FILE_GIT_AUTHOR_NAME', "${SEED_CONFIG_FILE_GIT_AUTHOR_NAME}") env('SEED_CONFIG_FILE_GIT_AUTHOR_CREDS_ID', "${SEED_CONFIG_FILE_GIT_AUTHOR_CREDS_ID}") + env('SEED_CONFIG_FILE_GIT_AUTHOR_PUSH_CREDS_ID', "${SEED_CONFIG_FILE_GIT_AUTHOR_PUSH_CREDS_ID}") env('SEED_CONFIG_FILE_GIT_BRANCH', "${SEED_CONFIG_FILE_GIT_BRANCH}") env('SEED_CONFIG_FILE_PATH', "${SEED_CONFIG_FILE_PATH}") diff --git a/dsl/seed/jobs/seed_job_branch.groovy b/dsl/seed/jobs/seed_job_branch.groovy index 9ccdb5684..ae5beea5b 100644 --- a/dsl/seed/jobs/seed_job_branch.groovy +++ b/dsl/seed/jobs/seed_job_branch.groovy @@ -143,6 +143,7 @@ pipelineJob("${GENERATION_BRANCH}/tools/toggle-dsl-triggers") { env('SEED_CONFIG_FILE_GIT_REPOSITORY', "${SEED_CONFIG_FILE_GIT_REPOSITORY}") env('SEED_CONFIG_FILE_GIT_AUTHOR_NAME', "${SEED_CONFIG_FILE_GIT_AUTHOR_NAME}") env('SEED_CONFIG_FILE_GIT_AUTHOR_CREDS_ID', "${SEED_CONFIG_FILE_GIT_AUTHOR_CREDS_ID}") + env('SEED_CONFIG_FILE_GIT_AUTHOR_PUSH_CREDS_ID', "${SEED_CONFIG_FILE_GIT_AUTHOR_PUSH_CREDS_ID}") env('SEED_CONFIG_FILE_GIT_BRANCH', "${SEED_CONFIG_FILE_GIT_BRANCH}") env('SEED_CONFIG_FILE_PATH', "${SEED_CONFIG_FILE_PATH}") diff --git a/dsl/seed/jobs/seed_job_main.groovy b/dsl/seed/jobs/seed_job_main.groovy index cae19621f..74ec938f0 100644 --- a/dsl/seed/jobs/seed_job_main.groovy +++ b/dsl/seed/jobs/seed_job_main.groovy @@ -53,6 +53,10 @@ String getSeedConfigFileGitAuthorCredsId() { return SEED_CONFIG_FILE_GIT_AUTHOR_CREDS_ID ?: DEFAULT_CREDENTIALS_ID } +String getSeedConfigFileGitAuthorPushCredsId() { + return SEED_CONFIG_FILE_GIT_AUTHOR_PUSH_CREDS_ID ?: DEFAULT_CREDENTIALS_ID +} + String getSeedConfigFileGitBranch() { return SEED_CONFIG_FILE_GIT_BRANCH ?: 'main' } diff --git a/dsl/seed/src/main/groovy/org/kie/jenkins/jobdsl/KogitoJobTemplate.groovy b/dsl/seed/src/main/groovy/org/kie/jenkins/jobdsl/KogitoJobTemplate.groovy index c32d02af1..cbd49a708 100644 --- a/dsl/seed/src/main/groovy/org/kie/jenkins/jobdsl/KogitoJobTemplate.groovy +++ b/dsl/seed/src/main/groovy/org/kie/jenkins/jobdsl/KogitoJobTemplate.groovy @@ -549,6 +549,9 @@ class KogitoJobTemplate { scriptPath(jenkinsFilePath) } } + configure { + it / disabled << Utils.isDeployDisabled(script) + } branchSources { github { id(Utils.getRepoName(script)) // IMPORTANT: use a constant and unique identifier diff --git a/dsl/seed/src/main/groovy/org/kie/jenkins/jobdsl/KogitoJobUtils.groovy b/dsl/seed/src/main/groovy/org/kie/jenkins/jobdsl/KogitoJobUtils.groovy index 76d42f5f7..3d76daef3 100644 --- a/dsl/seed/src/main/groovy/org/kie/jenkins/jobdsl/KogitoJobUtils.groovy +++ b/dsl/seed/src/main/groovy/org/kie/jenkins/jobdsl/KogitoJobUtils.groovy @@ -74,7 +74,8 @@ class KogitoJobUtils { BUILD_BRANCH_NAME: Utils.getGitBranch(script), GIT_AUTHOR: Utils.getGitAuthor(script), - AUTHOR_CREDS_ID: Utils.getGitAuthorCredsId(script), + GIT_AUTHOR_CREDS_ID: Utils.getGitAuthorCredsId(script), + GIT_AUTHOR_PUSH_CREDS_ID: Utils.getGitAuthorPushCredsId(script), ]) if (mavenUpdate) { mavenUpdate.modules ? jobParams.env.put('MAVEN_MODULES', JsonOutput.toJson(mavenUpdate.modules)) : null @@ -131,13 +132,14 @@ class KogitoJobUtils { PROPERTIES_FILENAME: KogitoConstants.PIPELINE_PROPERTIES_FILENAME, - GITHUB_TOKEN_CREDS_ID: Utils.getGitAuthorTokenCredsId(script), + GIT_AUTHOR_TOKEN_CREDS_ID: Utils.getGitAuthorTokenCredsId(script), - SEED_BRANCH_CONFIG_FILE_GIT_REPOSITORY: Utils.getBindingValue(script, 'SEED_CONFIG_FILE_GIT_REPOSITORY'), - SEED_BRANCH_CONFIG_FILE_GIT_AUTHOR_NAME: Utils.getBindingValue(script, 'SEED_CONFIG_FILE_GIT_AUTHOR_NAME'), - SEED_BRANCH_CONFIG_FILE_GIT_AUTHOR_CREDS_ID: Utils.getBindingValue(script, 'SEED_CONFIG_FILE_GIT_AUTHOR_CREDS_ID'), - SEED_BRANCH_CONFIG_FILE_GIT_BRANCH: Utils.getBindingValue(script, 'SEED_CONFIG_FILE_GIT_BRANCH'), - SEED_BRANCH_CONFIG_FILE_PATH: Utils.getBindingValue(script, 'SEED_CONFIG_FILE_PATH'), + SEED_CONFIG_FILE_GIT_REPOSITORY: Utils.getBindingValue(script, 'SEED_CONFIG_FILE_GIT_REPOSITORY'), + SEED_CONFIG_FILE_GIT_AUTHOR_NAME: Utils.getBindingValue(script, 'SEED_CONFIG_FILE_GIT_AUTHOR_NAME'), + SEED_CONFIG_FILE_GIT_AUTHOR_CREDS_ID: Utils.getBindingValue(script, 'SEED_CONFIG_FILE_GIT_AUTHOR_CREDS_ID'), + SEED_CONFIG_FILE_GIT_AUTHOR_PUSH_CREDS_ID: Utils.getBindingValue(script, 'SEED_CONFIG_FILE_GIT_AUTHOR_PUSH_CREDS_ID'), + SEED_CONFIG_FILE_GIT_BRANCH: Utils.getBindingValue(script, 'SEED_CONFIG_FILE_GIT_BRANCH'), + SEED_CONFIG_FILE_PATH: Utils.getBindingValue(script, 'SEED_CONFIG_FILE_PATH'), ]) JobParamsUtils.setupJobParamsSeedRepoEnv(script, jobParams) def job = KogitoJobTemplate.createPipelineJob(script, jobParams) @@ -163,15 +165,14 @@ class KogitoJobUtils { jobParams.env.putAll([ JENKINS_EMAIL_CREDS_ID: Utils.getJenkinsEmailCredsId(script), BUILD_BRANCH_NAME: Utils.getGitBranch(script), - GIT_AUTHOR: Utils.getGitAuthor(script), - GIT_AUTHOR_CREDENTIALS_ID: Utils.getGitAuthorCredsId(script), - QUARKUS_PLATFORM_AUTHOR_NAME: Utils.getGitQuarkusAuthor(script), - QUARKUS_PLATFORM_AUTHOR_CREDENTIALS_ID: Utils.getGitQuarkusAuthorCredsId(script), + GIT_QUARKUS_AUTHOR: Utils.getGitQuarkusAuthor(script), + GIT_QUARKUS_AUTHOR_CREDS_ID: Utils.getGitQuarkusAuthorCredsId(script), PROJECT_NAME: project, - FORK_GIT_AUTHOR: Utils.getGitForkAuthorName(script), - FORK_GIT_AUTHOR_CREDS_ID: Utils.getGitForkAuthorCredsId(script), + GIT_FORK_AUTHOR: Utils.getGitForkAuthorName(script), + GIT_FORK_AUTHOR_CREDS_ID: Utils.getGitForkAuthorCredsId(script), + GIT_FORK_AUTHOR_PUSH_CREDS_ID: Utils.getGitForkAuthorPushCredsId(script), ]) def job = KogitoJobTemplate.createPipelineJob(script, jobParams) job?.with { @@ -208,7 +209,7 @@ class KogitoJobUtils { BUILD_BRANCH_NAME: Utils.getGitBranch(script), GIT_AUTHOR: Utils.getGitAuthor(script), - AUTHOR_CREDS_ID: Utils.getGitAuthorCredsId(script), + GIT_AUTHOR_CREDS_ID: Utils.getGitAuthorCredsId(script), GIT_AUTHOR_TOKEN_CREDENTIALS_ID: Utils.getGitAuthorTokenCredsId(script), SCRIPTS_CALLS: JsonOutput.toJson(scriptCalls), @@ -277,7 +278,7 @@ class KogitoJobUtils { * See also `createBranchBuildChainJob` method */ static def createNightlyBuildChainBuildAndDeployJob(def script, String envName = '', String repository, Map extraEnv = [:], boolean enableNotification = false, Closure defaultJobParamsGetter = JobParamsUtils.DEFAULT_PARAMS_GETTER) { - def jobParams = JobParamsUtils.getSeedJobParamsWithEnv(script, "${Utils.getRepositoryJobDisplayName(script, repository)}.build-and-deploy", JobType.NIGHTLY, envName, KogitoConstants.BUILD_CHAIN_JENKINSFILE, "Build & Test for ${repository} using the build-chain", defaultJobParamsGetter) + def jobParams = JobParamsUtils.getSeedJobParamsWithEnv(script, "${Utils.getRepositoryJobDisplayName(script, repository)}.build-and-deploy", JobType.NIGHTLY, envName, KogitoConstants.BUILD_CHAIN_JENKINSFILE, "Build & Deploy for ${repository} using the build-chain", defaultJobParamsGetter) JobParamsUtils.setupJobParamsDeployConfiguration(script, jobParams) jobParams.env.putAll(extraEnv) return createBranchBuildChainJob(script, jobParams, repository, enableNotification, envName) 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 1cb22c954..0e3b3adf2 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 @@ -142,6 +142,14 @@ class Utils { return getBindingValue(script, 'GIT_AUTHOR_TOKEN_CREDENTIALS_ID') } + static String getGitAuthorPushCredsId(def script) { + return getBindingValue(script, 'GIT_AUTHOR_PUSH_CREDENTIALS_ID') + } + + static String getGitAuthorPushTokenCredsId(def script) { + return getBindingValue(script, 'GIT_AUTHOR_PUSH_TOKEN_CREDENTIALS_ID') + } + static String getGitForkAuthorName(def script) { return getBindingValue(script, 'GIT_FORK_AUTHOR_NAME') } @@ -150,6 +158,10 @@ class Utils { return getBindingValue(script, 'GIT_FORK_AUTHOR_CREDENTIALS_ID') } + static String getGitForkAuthorPushCredsId(def script) { + return getBindingValue(script, 'GIT_FORK_AUTHOR_PUSH_CREDENTIALS_ID') + } + static String getGitQuarkusBranch(def script) { return getBindingValue(script, 'GIT_QUARKUS_BRANCH') } @@ -174,6 +186,14 @@ class Utils { return getBindingValue(script, "${repoName.toUpperCase()}_GIT_AUTHOR_CREDENTIALS_ID") } + static String getRepositoryGitAuthorPushCredentialsId(def script, String repoName) { + return getBindingValue(script, "${repoName.toUpperCase()}_GIT_AUTHOR_PUSH_CREDENTIALS_ID") + } + + static String getRepositoryGitAuthorPushTokenCredentialsId(def script, String repoName) { + return getBindingValue(script, "${repoName.toUpperCase()}_GIT_AUTHOR_PUSH_TOKEN_CREDENTIALS_ID") + } + static String getRepositoryJenkinsConfigPath(def script, String repoName) { return getBindingValue(script, "${repoName.toUpperCase()}_JENKINS_CONFIG_PATH") } diff --git a/dsl/seed/src/test/groovy/org/kie/jenkins/jobdsl/JobScriptsSpec.groovy b/dsl/seed/src/test/groovy/org/kie/jenkins/jobdsl/JobScriptsSpec.groovy index 3d41d6b5f..96ae44aef 100644 --- a/dsl/seed/src/test/groovy/org/kie/jenkins/jobdsl/JobScriptsSpec.groovy +++ b/dsl/seed/src/test/groovy/org/kie/jenkins/jobdsl/JobScriptsSpec.groovy @@ -80,6 +80,7 @@ class JobScriptsSpec extends Specification { envVars.put('SEED_CONFIG_FILE_GIT_REPOSITORY', 'SEED_CONFIG_FILE_GIT_REPOSITORY') envVars.put('SEED_CONFIG_FILE_GIT_AUTHOR_NAME', 'SEED_CONFIG_FILE_GIT_AUTHOR_NAME') envVars.put('SEED_CONFIG_FILE_GIT_AUTHOR_CREDS_ID', 'SEED_CONFIG_FILE_GIT_AUTHOR_CREDS_ID') + envVars.put('SEED_CONFIG_FILE_GIT_AUTHOR_PUSH_CREDS_ID', 'SEED_CONFIG_FILE_GIT_AUTHOR_PUSH_CREDS_ID') envVars.put('SEED_CONFIG_FILE_GIT_BRANCH', 'SEED_CONFIG_FILE_GIT_BRANCH') envVars.put('SEED_CONFIG_FILE_PATH', 'SEED_CONFIG_FILE_PATH')