Skip to content

Commit

Permalink
Update Jenkinsfile.deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
radtriste authored Aug 4, 2023
1 parent 7f6ccc5 commit 16a21b1
Showing 1 changed file with 12 additions and 21 deletions.
33 changes: 12 additions & 21 deletions .ci/jenkins/Jenkinsfile.deploy
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down Expand Up @@ -82,7 +82,7 @@ pipeline {
steps {
script {
dir(getRepoName()) {
prepareForPR()
githubscm.createBranch(getPRBranch())
}
}
}
Expand Down Expand Up @@ -174,8 +174,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())
}
Expand Down Expand Up @@ -211,18 +211,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() {
Expand Down Expand Up @@ -262,6 +257,10 @@ String getGitAuthor() {
return "${GIT_AUTHOR}"
}

String getGitAuthorCredsID() {
return env.AUTHOR_CREDS_ID
}

String getBuildBranch() {
return params.BUILD_BRANCH_NAME
}
Expand All @@ -274,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) {
Expand Down

0 comments on commit 16a21b1

Please sign in to comment.