Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 13 additions & 27 deletions JenkinsJobs/Releng/prepareNextDevCycle.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ pipeline {
checkout scm
script { // Always load the script from the very same state this pipeline is loaded (to ensure consistency)
utilities = load "JenkinsJobs/shared/utilities.groovy"
utilities.setDryRun(params.DRY_RUN)
githubAPI = load "JenkinsJobs/shared/githubAPI.groovy"
githubAPI.setDryRun(params.DRY_RUN)
}
Expand Down Expand Up @@ -344,28 +345,14 @@ pipeline {
}
stage('Push preparation branches') {
steps {
sshagent (['github-bot-ssh']) {
sh '''#!/bin/bash -xe
function pushNewCommitsToPreparationBranch() {
pushURL=$(git config remote.origin.url)
# Switch to SSH, if the configured URL uses HTTPS (we can only push with SSH)
if [[ "$pushURL" == http* ]]; then
pushURL=$(echo $pushURL|sed --expression 's|https://github.com/|[email protected]:|')
fi
if [[ ${DRY_RUN} == 'true' ]]; then
dryRunFlag='--dry-run'
fi
git push ${dryRunFlag} ${pushURL} "master:refs/heads/prepare-R${NEXT_RELEASE_VERSION}"
git push ${dryRunFlag} ${pushURL} "${MAINTENANCE_BRANCH}:refs/heads/${MAINTENANCE_BRANCH}"
}
pushNewCommitsToPreparationBranch
export -f pushNewCommitsToPreparationBranch
git submodule foreach 'pushNewCommitsToPreparationBranch'

# Push preparation of the maintenance to a separate branch (not directly to the maintenance branch),
# to enable creating a PR against the maintenance branch from it.
git push ${dryRunFlag} ${pushURL} "prepareMaintenance:refs/heads/prepare-${MAINTENANCE_BRANCH}"
'''
script {
utilities.runHereAndForEachGitSubmodule{
utilities.gitPushBranch('master', "prepare-R${NEXT_RELEASE_VERSION}")
utilities.gitPushBranch("${MAINTENANCE_BRANCH}", "${MAINTENANCE_BRANCH}")
}
// Push preparation of the maintenance to a separate branch (not directly to the maintenance branch),
// to enable creating a PR against the maintenance branch from it.
utilities.gitPushBranch('prepareMaintenance', "prepare-${MAINTENANCE_BRANCH}")
}
}
}
Expand All @@ -382,14 +369,13 @@ pipeline {
- Updating the previous release version to the current Release-Candidate: `${PREVIOUS_RELEASE_CANDIDATE_ID}`
""".stripIndent(), prBranch)

def submodulePaths = sh(script: "git submodule --quiet foreach 'echo \$sm_path'", returnStdout: true).trim().split('\\s')
for (submodulePath in submodulePaths) {
def diff = sh(script:"cd ${submodulePath} && git diff master origin/master --shortstat", returnStdout: true).trim()
utilities.forEachGitSubmodule{ submodulePath ->
def diff = sh(script:"git diff master origin/master --shortstat", returnStdout: true).trim()
if (diff.isEmpty()) {
echo "Skipping submodule without changes: ${submodulePath}"
continue
return
}
def submoduleURL = sh(script: "cd ${submodulePath} && git config remote.origin.url", returnStdout: true).trim()
def submoduleURL = sh(script: "git config remote.origin.url", returnStdout: true).trim()
// Extract repository path from e.g.: https://github.com/eclipse-platform/eclipse.platform.git
def expectedPrefix = 'https://github.com/'
def expectedSuffix = '.git'
Expand Down
45 changes: 11 additions & 34 deletions JenkinsJobs/Releng/promoteBuild.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ pipeline {
checkout scm
script { // Always load the script from the very same state this pipeline is loaded (to ensure consistency)
utilities = load "JenkinsJobs/shared/utilities.groovy"
utilities.setDryRun(params.DRY_RUN)
githubAPI = load "JenkinsJobs/shared/githubAPI.groovy"
githubAPI.setDryRun(params.DRY_RUN)
}
Expand Down Expand Up @@ -144,25 +145,12 @@ pipeline {
}
steps {
dir("${WORKSPACE}/repository") {
sshagent(['github-bot-ssh']) {
sh '''#!/bin/bash -xe
function tagBuild() {
pushURL=$(git config remote.origin.url)
if [[ "$pushURL" == http* ]]; then
# Change to SSH, if the configured URL uses HTTPS (we can only push with SSH)
pushURL=$(echo $pushURL|sed --expression 's|https://github.com/|[email protected]:|')
fi
if [[ ${DRY_RUN} == 'true' ]]; then
dryRunFlag='--dry-run'
fi
# Enforce the (re-)creation of the tag in case of a very late respin
git tag --force -a -m "${SIGNOFF_BUG}" ${TAG} HEAD
git push --force --verbose ${dryRunFlag} ${pushURL} tag ${TAG}
}
tagBuild
export -f tagBuild
git submodule foreach 'tagBuild'
'''
script {
utilities.runHereAndForEachGitSubmodule{
// Enforce the (re-)creation of the tag in case of a very late respin
sh 'git tag --force --annotate --message="${SIGNOFF_BUG}" ${TAG} HEAD'
utilities.gitPushTag("${TAG}", /*force*/ true)
}
}
}
}
Expand Down Expand Up @@ -263,21 +251,10 @@ pipeline {
git log origin/master..master --patch-with-stat --summary
git log origin/${MAINTENANCE_BRANCH}..updateMaintenance --patch-with-stat --summary
'''
sshagent(['github-bot-ssh']) {
sh '''#!/bin/bash -xe
pushURL=$(git config remote.origin.url)
# Switch to SSH, if the configured URL uses HTTPS (we can only push with SSH)
if [[ "$pushURL" == http* ]]; then
pushURL=$(echo $pushURL|sed --expression 's|https://github.com/|[email protected]:|')
fi
if [[ ${DRY_RUN} == 'true' ]]; then
dryRunFlag='--dry-run'
fi
git push --force ${dryRunFlag} ${pushURL} "master:refs/heads/update-build-to-R${BUILD_MAJOR}.${BUILD_MINOR}"
git push --force ${dryRunFlag} ${pushURL} "updateMaintenance:refs/heads/update-${MAINTENANCE_BRANCH}"
'''
}
script { // Create PRs agains the master and maintenance branch
script { // Push branches and create PRs agains the master and maintenance branch
utilities.gitPushBranch('master', "update-build-to-R${BUILD_MAJOR}.${BUILD_MINOR}", /*force*/ true)
utilities.gitPushBranch('updateMaintenance', "update-${MAINTENANCE_BRANCH}", /*force*/ true)

def masterPR = githubAPI.createPullRequest('eclipse-platform/eclipse.platform.releng.aggregator',
"Update previous release version to ${BUILD_MAJOR}.${BUILD_MINOR} GA across build scripts", """\
Update the the `${MAINTENANCE_BRANCH}` branch with final ${BUILD_MAJOR}.${BUILD_MINOR} release version.
Expand Down
41 changes: 41 additions & 0 deletions JenkinsJobs/shared/utilities.groovy
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@

@groovy.transform.Field
def boolean IS_DRY_RUN = true

def setDryRun(boolean isDryRun) {
IS_DRY_RUN = isDryRun
}

def replaceInFile(String filePath, Map<String,String> replacements) {
replaceAllInFile(filePath, replacements.collectEntries{ k, v -> [java.util.regex.Pattern.quote(k), v] });
}
Expand All @@ -15,6 +22,20 @@ def replaceAllInFile(String filePath, Map<String,String> replacements) {
writeFile(file:filePath, text: content)
}

def runHereAndForEachGitSubmodule(Closure task) {
task.call()
forEachGitSubmodule(task)
}

def forEachGitSubmodule(Closure task) {
def submodulePaths = sh(script: "git submodule --quiet foreach 'echo \$sm_path'", returnStdout: true).trim().split('\\s')
for (submodulePath in submodulePaths) {
dir("${submodulePath}") {
task.call(submodulePath)
}
}
}

def gitCommitAllExcludingSubmodules(String commitMessage) {
withEnv(["COMMIT_MESSAGE=${commitMessage}"]) {
sh '''
Expand All @@ -26,4 +47,24 @@ def gitCommitAllExcludingSubmodules(String commitMessage) {
}
}

def gitPushBranch(String localBranch, String remoteTargetBranch, boolean force = false) {
gitPush("${localBranch}:refs/heads/${remoteTargetBranch}", force)
}

def gitPushTag(String tagName, boolean force = false) {
gitPush("tag ${tagName}", force)
}

private void gitPush(String refSpec, boolean force) {
def dryRunOption = IS_DRY_RUN ? '--dry-run' : ''
def forceOption = force ? '--force' : ''
sshagent(['github-bot-ssh']) {
sh """#!/bin/bash -xe
# Switch to SSH, if the configured URL uses HTTPS (we can only push with SSH)
pushURL=\$(git config remote.origin.url | sed --expression 's|https://github.com/|[email protected]:|')
git push ${dryRunOption} ${forceOption} "\${pushURL}" ${refSpec}
"""
}
}

return this
Loading