diff --git a/.ci/jenkins/Jenkinsfile.deploy b/.ci/jenkins/Jenkinsfile.deploy index 917b7f1b98..1f088ddfe1 100644 --- a/.ci/jenkins/Jenkinsfile.deploy +++ b/.ci/jenkins/Jenkinsfile.deploy @@ -34,7 +34,7 @@ pipeline { MAVEN_OPTS = '-Xms1024m -Xmx4g' NODE_OPTIONS = '--max_old_space_size=4096' - BOT_BRANCH_HASH = "${util.generateHash(10)}" + PR_BRANCH_HASH = "${util.generateHash(10)}" MAVEN_DEPLOY_LOCAL_DIR = "${WORKSPACE}/maven_deploy_dir" } @@ -80,7 +80,9 @@ pipeline { expression { return isRelease() || isCreatePr() } } steps { - prepareForPR() + dir(getRepoName()) { + githubscm.createBranch(getPRBranch()) + } } } stage('Update project version') { @@ -161,8 +163,8 @@ pipeline { post { success { script { - setDeployPropertyIfNeeded("${getRepoName()}.pr.source.uri", "https://github.com/${getBotAuthor()}/${getRepoName()}") - setDeployPropertyIfNeeded("${getRepoName()}.pr.source.ref", getBotBranch()) + setDeployPropertyIfNeeded("${getRepoName()}.pr.source.uri", "https://github.com/${getGitAuthor()}/${getRepoName()}") + setDeployPropertyIfNeeded("${getRepoName()}.pr.source.ref", getPRBranch()) setDeployPropertyIfNeeded("${getRepoName()}.pr.target.uri", "https://github.com/${getGitAuthor()}/${getRepoName()}") setDeployPropertyIfNeeded("${getRepoName()}.pr.target.ref", getBuildBranch()) } @@ -218,13 +220,6 @@ void checkoutRepo() { } } -void prepareForPR() { - dir(getRepoName()) { - githubscm.forkRepo(getBotAuthorCredsID()) - githubscm.createBranch(getBotBranch()) - } -} - void commitAndCreatePR() { def commitMsg = "[${getBuildBranch()}] Update version to ${getProjectVersion()}" def prBody = "Generated by build ${BUILD_TAG}: ${BUILD_URL}." @@ -235,8 +230,8 @@ void commitAndCreatePR() { } dir(getRepoName()) { githubscm.commitChanges(commitMsg, { githubscm.findAndStageNotIgnoredFiles('pom.xml') }) - githubscm.pushObject('origin', getBotBranch(), getBotAuthorCredsID()) - deployProperties["${getRepoName()}.pr.link"] = githubscm.createPRWithLabels(commitMsg, prBody, getBuildBranch(), ['skip-ci'] as String[], getBotAuthorCredsID()) + githubscm.pushObject('origin', getPRBranch(), getGitAuthorCredsID()) + deployProperties["${getRepoName()}.pr.link"] = githubscm.createPRWithLabels(commitMsg, prBody, getBuildBranch(), ['skip-ci'] as String[], getGitAuthorCredsID()) } } @@ -277,16 +272,8 @@ String getProjectVersion() { return params.PROJECT_VERSION } -String getBotBranch() { - return "${getProjectVersion()}-${env.BOT_BRANCH_HASH}" -} - -String getBotAuthor() { - return env.GIT_AUTHOR_BOT -} - -String getBotAuthorCredsID() { - return env.BOT_CREDENTIALS_ID +String getPRBranch() { + return "${getProjectVersion()}-${env.PR_BRANCH_HASH}" } void setDeployPropertyIfNeeded(String key, def value) { diff --git a/.ci/jenkins/Jenkinsfile.promote b/.ci/jenkins/Jenkinsfile.promote index c81a959eb0..4b58c8b6da 100644 --- a/.ci/jenkins/Jenkinsfile.promote +++ b/.ci/jenkins/Jenkinsfile.promote @@ -30,7 +30,7 @@ pipeline { KOGITO_CI_EMAIL_TO = credentials("${JENKINS_EMAIL_CREDS_ID}") - BOT_BRANCH_HASH = "${util.generateHash(10)}" + PR_BRANCH_HASH = "${util.generateHash(10)}" NODE_OPTIONS = '--max_old_space_size=4096' } @@ -83,8 +83,9 @@ pipeline { } steps { script { - dir('bot') { - prepareForPR() + dir('pr') { + checkoutRepo() + githubscm.createBranch(getSnapshotBranch()) maven.mvnVersionsUpdateParentAndChildModules(getMavenCommand(), getSnapshotVersion(), true) @@ -205,10 +206,6 @@ String getGitAuthorCredsID() { return env.AUTHOR_CREDS_ID } -String getBotAuthorCredsID() { - return env.BOT_CREDENTIALS_ID -} - String getDeployPrLink() { return getDeployProperty("${getRepoName()}.pr.link") } @@ -222,7 +219,7 @@ void setPipelinePrLink(String value) { } String getSnapshotBranch() { - return "${getSnapshotVersion().toLowerCase()}-${env.BOT_BRANCH_HASH}" + return "${getSnapshotVersion().toLowerCase()}-${env.PR_BRANCH_HASH}" } ////////////////////////////////////////////////////////////////////////////// @@ -249,19 +246,13 @@ void tagLatest() { } } -void prepareForPR() { - checkoutRepo() - githubscm.forkRepo(getBotAuthorCredsID()) - githubscm.createBranch(getSnapshotBranch()) -} - void commitAndCreatePR() { def commitMsg = "[${getBuildBranch()}] Update version to ${getSnapshotVersion()}" def prBody = "Generated by build ${BUILD_TAG}: ${BUILD_URL}.\nPlease do not merge, it should be merged automatically after testing." githubscm.commitChanges(commitMsg, { githubscm.findAndStageNotIgnoredFiles('pom.xml') }) - githubscm.pushObject('origin', getSnapshotBranch(), getBotAuthorCredsID()) - setPipelinePrLink(githubscm.createPR(commitMsg, prBody, getBuildBranch(), getBotAuthorCredsID())) + githubscm.pushObject('origin', getSnapshotBranch(), getGitAuthorCredsID()) + setPipelinePrLink(githubscm.createPR(commitMsg, prBody, getBuildBranch(), getGitAuthorCredsID())) } MavenCommand getMavenCommand() { diff --git a/.ci/jenkins/dsl/jobs.groovy b/.ci/jenkins/dsl/jobs.groovy index b194b801fb..e189c3a260 100644 --- a/.ci/jenkins/dsl/jobs.groovy +++ b/.ci/jenkins/dsl/jobs.groovy @@ -203,8 +203,6 @@ void setupDeployJob(JobType jobType, String envName = '') { AUTHOR_CREDS_ID: "${GIT_AUTHOR_CREDENTIALS_ID}", GITHUB_TOKEN_CREDS_ID: "${GIT_AUTHOR_TOKEN_CREDENTIALS_ID}", - GIT_AUTHOR_BOT: "${GIT_BOT_AUTHOR_NAME}", - BOT_CREDENTIALS_ID: "${GIT_BOT_AUTHOR_CREDENTIALS_ID}", MAVEN_DEPENDENCIES_REPOSITORY: "${MAVEN_ARTIFACTS_REPOSITORY}", MAVEN_DEPLOY_REPOSITORY: "${MAVEN_ARTIFACTS_REPOSITORY}", @@ -251,8 +249,6 @@ void setupPromoteJob(JobType jobType) { AUTHOR_CREDS_ID: "${GIT_AUTHOR_CREDENTIALS_ID}", GITHUB_TOKEN_CREDS_ID: "${GIT_AUTHOR_TOKEN_CREDENTIALS_ID}", - GIT_AUTHOR_BOT: "${GIT_BOT_AUTHOR_NAME}", - BOT_CREDENTIALS_ID: "${GIT_BOT_AUTHOR_CREDENTIALS_ID}", MAVEN_SETTINGS_CONFIG_FILE_ID: "${MAVEN_SETTINGS_FILE_ID}", MAVEN_DEPENDENCIES_REPOSITORY: "${MAVEN_ARTIFACTS_REPOSITORY}",