@@ -87,6 +87,7 @@ pipeline {
8787 checkout scm
8888 script { // Always load the script from the very same state this pipeline is loaded (to ensure consistency)
8989 utilities = load "JenkinsJobs/shared/utilities.groovy"
90+ utilities.setDryRun(params.DRY_RUN)
9091 githubAPI = load "JenkinsJobs/shared/githubAPI.groovy"
9192 githubAPI.setDryRun(params.DRY_RUN)
9293 }
@@ -344,28 +345,14 @@ pipeline {
344345 }
345346 stage('Push preparation branches') {
346347 steps {
347- sshagent (['github-bot-ssh']) {
348- sh '''#!/bin/bash -xe
349- function pushNewCommitsToPreparationBranch() {
350- pushURL=$(git config remote.origin.url)
351- # Switch to SSH, if the configured URL uses HTTPS (we can only push with SSH)
352- if [[ "$pushURL" == http* ]]; then
353- pushURL=$(echo $pushURL|sed --expression 's|https://github.com/|
[email protected] :|')
354- fi
355- if [[ ${DRY_RUN} == 'true' ]]; then
356- dryRunFlag='--dry-run'
357- fi
358- git push ${dryRunFlag} ${pushURL} "master:refs/heads/prepare-R${NEXT_RELEASE_VERSION}"
359- git push ${dryRunFlag} ${pushURL} "${MAINTENANCE_BRANCH}:refs/heads/${MAINTENANCE_BRANCH}"
360- }
361- pushNewCommitsToPreparationBranch
362- export -f pushNewCommitsToPreparationBranch
363- git submodule foreach 'pushNewCommitsToPreparationBranch'
364-
365- # Push preparation of the maintenance to a separate branch (not directly to the maintenance branch),
366- # to enable creating a PR against the maintenance branch from it.
367- git push ${dryRunFlag} ${pushURL} "prepareMaintenance:refs/heads/prepare-${MAINTENANCE_BRANCH}"
368- '''
348+ script {
349+ utilities.runHereAndForEachGitSubmodule{
350+ utilities.gitPushBranch('master', "prepare-R${NEXT_RELEASE_VERSION}")
351+ utilities.gitPushBranch("${MAINTENANCE_BRANCH}", "${MAINTENANCE_BRANCH}")
352+ }
353+ // Push preparation of the maintenance to a separate branch (not directly to the maintenance branch),
354+ // to enable creating a PR against the maintenance branch from it.
355+ utilities.gitPushBranch('prepareMaintenance', "prepare-${MAINTENANCE_BRANCH}")
369356 }
370357 }
371358 }
@@ -382,14 +369,13 @@ pipeline {
382369 - Updating the previous release version to the current Release-Candidate: `${PREVIOUS_RELEASE_CANDIDATE_ID}`
383370 """.stripIndent(), prBranch)
384371
385- def submodulePaths = sh(script: "git submodule --quiet foreach 'echo \$sm_path'", returnStdout: true).trim().split('\\s')
386- for (submodulePath in submodulePaths) {
387- def diff = sh(script:"cd ${submodulePath} && git diff master origin/master --shortstat", returnStdout: true).trim()
372+ utilities.forEachGitSubmodule{ submodulePath ->
373+ def diff = sh(script:"git diff master origin/master --shortstat", returnStdout: true).trim()
388374 if (diff.isEmpty()) {
389375 echo "Skipping submodule without changes: ${submodulePath}"
390- continue
376+ return
391377 }
392- def submoduleURL = sh(script: "cd ${submodulePath} && git config remote.origin.url", returnStdout: true).trim()
378+ def submoduleURL = sh(script: "git config remote.origin.url", returnStdout: true).trim()
393379 // Extract repository path from e.g.: https://github.com/eclipse-platform/eclipse.platform.git
394380 def expectedPrefix = 'https://github.com/'
395381 def expectedSuffix = '.git'
0 commit comments