Skip to content

Commit

Permalink
[BXMSPROD-2121] allow target and source branches to have different na…
Browse files Browse the repository at this point in the history
…mes in sync-branches job (#1540)
  • Loading branch information
rgdoliveira authored Oct 31, 2023
1 parent 48226e8 commit 64d6280
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 3 additions & 2 deletions job-dsls/jobs/prod/prod_sync_branches.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ pipelineJob("${folderPath}/sync-branches") {
description('This job sync branches of a repository from different GitHub organizations.')

parameters {
stringParam('REPOSITORIES', '', 'List of repositories separated by comma, i.e. kogito-runtimes,kogito-apps')
stringParam('BRANCH', '', 'The branch that is going to be synced, i.e. 8.45.x')
stringParam('REPOSITORIES', '', 'List of repositories to be synced separated by comma, i.e. kogito-runtimes,kogito-apps')
stringParam('SOURCE_ORGANIZATION', 'apache', 'The GitHub organization where the original branch is')
stringParam('SOURCE_BRANCH', '', 'The source branch that is going to be synced, i.e. main')
stringParam('TARGET_ORGANIZATION', 'kiegroup', 'The GitHub organization where the branch will be pushed')
stringParam('TARGET_BRANCH', '\${SOURCE_BRANCH}', 'The name of the branch that will be generated on target repository, i.e. main-apache')
}

logRotator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ pipeline {
stage('Print variables') {
steps {
println "[INFO] REPOSITORIES: ${REPOSITORIES}"
println "[INFO] BRANCH: ${BRANCH}"
println "[INFO] SOURCE_ORGANIZATION: ${SOURCE_ORGANIZATION}"
println "[INFO] SOURCE_BRANCH: ${SOURCE_BRANCH}"
println "[INFO] TARGET_ORGANIZATION: ${TARGET_ORGANIZATION}"
println "[INFO] TARGET_BRANCH: ${TARGET_BRANCH}"
}
}

Expand Down Expand Up @@ -45,7 +46,7 @@ pipeline {
def cloneSourceRepository(String repositoryName) {
def repository = !SOURCE_ORGANIZATION.equals("apache") ? repositoryName : "incubator-kie-${repositoryName}" // remove when incubator is removed from the repos name
def repositoryUrl = "https://github.com/${SOURCE_ORGANIZATION}/${repository}.git"
sh "git clone --branch ${BRANCH} ${repositoryUrl} ${repositoryName}"
sh "git clone --branch ${SOURCE_BRANCH} ${repositoryUrl} ${repositoryName}"
}

def addTargetAsRemote(String repositoryName) {
Expand All @@ -57,6 +58,9 @@ def addTargetAsRemote(String repositoryName) {

def pushBranch(String repositoryName) {
dir (repositoryName) {
githubscm.pushObject(TARGET_ORGANIZATION, BRANCH, "kie-ci3")
if (SOURCE_BRANCH != TARGET_BRANCH) {
githubscm.createBranch(TARGET_BRANCH)
}
githubscm.pushObject(TARGET_ORGANIZATION, TARGET_BRANCH, "kie-ci3")
}
}

0 comments on commit 64d6280

Please sign in to comment.