From 8f8f4e2c6644b53232770e24bd2bf3332bd3b8c4 Mon Sep 17 00:00:00 2001 From: radtriste Date: Wed, 2 Aug 2023 15:03:38 +0200 Subject: [PATCH] KOGITO-9671 Remove bot account usage --- .ci/jenkins/Jenkinsfile.deploy | 29 ++++++++--------------------- .ci/jenkins/Jenkinsfile.promote | 15 +++++---------- .ci/jenkins/dsl/jobs.groovy | 5 +---- 3 files changed, 14 insertions(+), 35 deletions(-) diff --git a/.ci/jenkins/Jenkinsfile.deploy b/.ci/jenkins/Jenkinsfile.deploy index 5379470543f..70d37211894 100644 --- a/.ci/jenkins/Jenkinsfile.deploy +++ b/.ci/jenkins/Jenkinsfile.deploy @@ -33,7 +33,7 @@ pipeline { // Keep here for visibility MAVEN_OPTS = '-Xms1024m -Xmx4g' - BOT_BRANCH_HASH = "${util.generateHash(10)}" + PR_BRANCH_HASH = "${util.generateHash(10)}" MAVEN_DEPLOY_LOCAL_DIR = "${WORKSPACE}/maven_deploy_dir" } @@ -82,7 +82,7 @@ pipeline { steps { script { dir(getRepoName()) { - prepareForPR() + githubscm.createBranch(getPRBranch()) } } } @@ -178,8 +178,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()) } @@ -215,18 +215,13 @@ void checkoutRepo() { checkout(githubscm.resolveRepository(getRepoName(), getGitAuthor(), getBuildBranch(), false)) } -void prepareForPR() { - githubscm.forkRepo(getBotAuthorCredsID()) - githubscm.createBranch(getBotBranch()) -} - void commitAndCreatePR() { def commitMsg = "[${getBuildBranch()}] Update version to ${getProjectVersion()}" def prBody = "Generated by build ${BUILD_TAG}: ${BUILD_URL}.\nPlease do not merge, it should be merged automatically." 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()) } void sendNotification() { @@ -278,16 +273,8 @@ String getDroolsVersion() { return params.DROOLS_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 b9a197c1997..6e2f29129bd 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)}" } stages { @@ -91,7 +91,7 @@ pipeline { } steps { script { - dir('bot') { + dir('pr') { prepareForPR() maven.mvnVersionsSet(getMavenCommand(), getSnapshotVersion(), true) @@ -219,10 +219,6 @@ String getGitAuthorCredsID() { return env.AUTHOR_CREDS_ID } -String getBotAuthorCredsID() { - return env.BOT_CREDENTIALS_ID -} - String getDeployPrLink() { return getDeployProperty("${getRepoName()}.pr.link") } @@ -236,7 +232,7 @@ void setPipelinePrLink(String value) { } String getSnapshotBranch() { - return "${getSnapshotVersion().toLowerCase()}-${env.BOT_BRANCH_HASH}" + return "${getSnapshotVersion().toLowerCase()}-${env.PR_BRANCH_HASH}" } ////////////////////////////////////////////////////////////////////////////// @@ -265,7 +261,6 @@ void tagLatest() { void prepareForPR() { checkoutRepo() - githubscm.forkRepo(getBotAuthorCredsID()) githubscm.createBranch(getSnapshotBranch()) } @@ -274,8 +269,8 @@ void commitAndCreatePR() { def prBody = "Generated by build ${BUILD_TAG}: ${BUILD_URL}.\nPlease do not merge, it should be merged automatically." 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(String directory = '') { diff --git a/.ci/jenkins/dsl/jobs.groovy b/.ci/jenkins/dsl/jobs.groovy index 83d60716ce6..3cbc6cde6e1 100644 --- a/.ci/jenkins/dsl/jobs.groovy +++ b/.ci/jenkins/dsl/jobs.groovy @@ -181,8 +181,7 @@ 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_UPLOAD_REPOSITORY_URL}", MAVEN_REPO_CREDS_ID: "${MAVEN_ARTIFACTS_UPLOAD_REPOSITORY_CREDS_ID}", @@ -232,8 +231,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}",