Skip to content

Commit 1f9fdba

Browse files
committed
[RelEng] Miscellaneous fixes and clean-ups in promotion/preparation
- Fix currently not working calls to gitCommitAllExcludingSubmodules(), because methods on objects may only be called in script blocks or methods. - Enable running the preparation of a new release with an I-build as PREVIOUS_RELEASE_CANDIDATE_ID. - Fix check of response status in githubAPI utility script. The status was compared as String with an integer and not parsed, leading to always false comparisons. - Skip checkout of maintenance branch for non release promotions - Remove unnecessary arguments of Maven invocations and other minor clean-ups
1 parent e6cf309 commit 1f9fdba

File tree

4 files changed

+58
-46
lines changed

4 files changed

+58
-46
lines changed

JenkinsJobs/Releng/prepareNextDevCycle.jenkinsfile

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,28 @@ pipeline {
2929
nextVersionMatcher = null // release matcher as it's not serializable
3030

3131
env.PREVIOUS_RELEASE_CANDIDATE_ID = readParameter('PREVIOUS_RELEASE_CANDIDATE_ID')
32-
def previousIdMatcher = env.PREVIOUS_RELEASE_CANDIDATE_ID =~ /(?<type>[SR])-(?<major>\d+)\.(?<minor>\d+)(\.(?<service>\d+))?(?<checkpoint>(M|RC)\d+[a-z]?)?-(?<date>\d{8})(?<time>\d{4})/
33-
if (!previousIdMatcher.matches()) {
32+
def previousIdMatcher = null
33+
if ((previousIdMatcher = env.PREVIOUS_RELEASE_CANDIDATE_ID =~ /(?<type>[SR])-(?<major>\d+)\.(?<minor>\d+)(\.(?<service>\d+))?(?<checkpoint>(M|RC)\d+[a-z]?)?-(?<date>\d{8})(?<time>\d{4})/).matches()) {
34+
def checkpoint = previousIdMatcher.group('checkpoint')
35+
assignEnvVariable('PREVIOUS_RELEASE_VERSION_MAJOR', previousIdMatcher.group('major'))
36+
assignEnvVariable('PREVIOUS_RELEASE_VERSION_MINOR', previousIdMatcher.group('minor'))
37+
assignEnvVariable('PREVIOUS_RELEASE_CANDIDATE_TAG', "${PREVIOUS_RELEASE_VERSION_MAJOR}.${PREVIOUS_RELEASE_VERSION_MINOR}${checkpoint}")
38+
def previousServiceVersion = previousIdMatcher.group('service') ?: '0'
39+
assignEnvVariable('PREVIOUS_RELEASE_CANDIDATE_GIT_TAG', "${previousIdMatcher.group('type')}${PREVIOUS_RELEASE_VERSION_MAJOR}_${PREVIOUS_RELEASE_VERSION_MINOR}${(checkpoint || previousServiceVersion != '0') ? ('_' + previousServiceVersion) : ''}${checkpoint ? ('_' + checkpoint) : ''}")
40+
41+
} else if ((previousIdMatcher = env.PREVIOUS_RELEASE_CANDIDATE_ID =~ /I(?<date>\d{8})-(?<time>\d{4})/).matches()) {
42+
def buildPropertiesTxt = sh(script: "curl --fail https://download.eclipse.org/eclipse/downloads/drops4/${PREVIOUS_RELEASE_CANDIDATE_ID}/buildproperties.txt", returnStdout: true)
43+
def buildProperties = readProperties(text: buildPropertiesTxt)
44+
assignEnvVariable('PREVIOUS_RELEASE_VERSION_MAJOR', buildProperties.STREAMMajor.replace('"','')) // Remove surrounding quotes
45+
assignEnvVariable('PREVIOUS_RELEASE_VERSION_MINOR', buildProperties.STREAMMinor.replace('"','')) // Remove surrounding quotes
46+
assignEnvVariable('PREVIOUS_RELEASE_CANDIDATE_TAG', "${PREVIOUS_RELEASE_CANDIDATE_ID}")
47+
assignEnvVariable('PREVIOUS_RELEASE_CANDIDATE_GIT_TAG', "${PREVIOUS_RELEASE_CANDIDATE_ID}")
48+
49+
} else {
3450
error "Unexpected format for PREVIOUS_RELEASE_CANDIDATE_ID: ${PREVIOUS_RELEASE_CANDIDATE_ID}"
3551
}
36-
def checkpoint = previousIdMatcher.group('checkpoint')
37-
def previousReleaseVersionService = previousIdMatcher.group('service') ?: '0'
38-
assignEnvVariable('PREVIOUS_RELEASE_VERSION_MAJOR', previousIdMatcher.group('major'))
39-
assignEnvVariable('PREVIOUS_RELEASE_VERSION_MINOR', previousIdMatcher.group('minor'))
4052
assignEnvVariable('PREVIOUS_RELEASE_VERSION', "${PREVIOUS_RELEASE_VERSION_MAJOR}.${PREVIOUS_RELEASE_VERSION_MINOR}")
41-
assignEnvVariable('PREVIOUS_RELEASE_CANDIDATE_TAG', "${PREVIOUS_RELEASE_VERSION}${checkpoint}")
4253
assignEnvVariable('PREVIOUS_RELEASE_CANDIDATE_I_BUILD', "I${previousIdMatcher.group('date')}-${previousIdMatcher.group('time')}")
43-
assignEnvVariable('PREVIOUS_RELEASE_CANDIDATE_GIT_TAG', "${previousIdMatcher.group('type')}${PREVIOUS_RELEASE_VERSION_MAJOR}_${PREVIOUS_RELEASE_VERSION_MINOR}${(checkpoint || previousReleaseVersionService != '0') ? ('_' + previousReleaseVersionService) : ''}${checkpoint ? ('_' + checkpoint) : ''}")
4454
previousIdMatcher = null // release matcher as it's not serializable
4555

4656
//TODO: Read the dates from the calender instead of provide a structured document somewhere?
@@ -100,14 +110,11 @@ pipeline {
100110
}
101111
}
102112
stage('Update Maven Version') {
103-
environment {
104-
MAVEN_ARGS = '-U -B -ntp'
105-
}
106113
steps {
107114
sh '''
108115
mvn org.eclipse.tycho:tycho-versions-plugin:set-version \
109116
-DnewVersion=${NEXT_RELEASE_VERSION}.0-SNAPSHOT
110-
mvn -f eclipse-platform-parent/pom.xml --non-recursive org.eclipse.tycho:tycho-versions-plugin:set-property \
117+
mvn -f eclipse-platform-parent/pom.xml tycho-versions:set-property \
111118
-Dproperties=releaseVersion,releaseYear,releaseMonth \
112119
-DnewReleaseVersion=${NEXT_RELEASE_VERSION} \
113120
-DnewReleaseYear=${NEXT_RELEASE_YEAR} \
@@ -155,13 +162,13 @@ pipeline {
155162
"(?<prefix># Schedule:.*\\R)(?s).*(?<suffix>\\R'''\\))" : "\${prefix}${I_BUILD_SCHEDULE}\${suffix}",
156163
])
157164

158-
utilities.commitAllChangesExcludingSubmodules("Update versions to ${NEXT_RELEASE_VERSION} in build scripts")
165+
gitCommitAllExcludingSubmodules("Update versions to ${NEXT_RELEASE_VERSION} in build scripts")
159166
}
160167
}
161168
stage('Move previous version to current RC') {
162169
steps {
163170
sh '''
164-
mvn -f eclipse-platform-parent/pom.xml --non-recursive org.eclipse.tycho:tycho-versions-plugin:set-property \
171+
mvn -f eclipse-platform-parent/pom.xml tycho-versions:set-property \
165172
-Dproperties=previous-release.baseline \
166173
"-DnewPrevious-release.baseline=https://download.eclipse.org/eclipse/updates/${PREVIOUS_RELEASE_VERSION}-I-builds/${PREVIOUS_RELEASE_CANDIDATE_I_BUILD}/"
167174
'''
@@ -183,7 +190,8 @@ pipeline {
183190
'previousReleaseVersion=.*' : "previousReleaseVersion=${PREVIOUS_RELEASE_CANDIDATE_TAG}",
184191
'previousReleaseVersionRepo=.*' : "previousReleaseVersionRepo=${PREVIOUS_RELEASE_VERSION}-I-builds",
185192
])
186-
utilities.commitAllChangesExcludingSubmodules("Move previous version to ${PREVIOUS_RELEASE_CANDIDATE_TAG} in build scripts")
193+
194+
gitCommitAllExcludingSubmodules("Move previous version to ${PREVIOUS_RELEASE_CANDIDATE_TAG} in build scripts")
187195
}
188196
}
189197
stage('Clear Qualifier-update files') {
@@ -243,7 +251,7 @@ pipeline {
243251
])
244252
sh "mv cje-production/streams/repositories_master.txt cje-production/streams/repositories_${MAINTENANCE_BRANCH}.txt"
245253

246-
utilities.commitAllChangesExcludingSubmodules("Move ${PREVIOUS_RELEASE_VERSION}-I builds to ${MAINTENANCE_BRANCH} branch")
254+
gitCommitAllExcludingSubmodules("Move ${PREVIOUS_RELEASE_VERSION}-I builds to ${MAINTENANCE_BRANCH} branch")
247255

248256
// Switch back to master for subsequent parts of this pipeline
249257
sh 'git checkout master'
@@ -274,7 +282,7 @@ pipeline {
274282
--fixed-strings "${PREVIOUS_RELEASE_VERSION}")
275283
# The eclipse-platform-parent/pom.xml contains the previous version in the baseline repository variable
276284
if [[ -z "${matchingFiles}" ]] || [[ "${matchingFiles}" == 'eclipse-platform-parent/pom.xml' ]]; then
277-
echo "No unexpected references to previous version ${PREVIOUS_RELEASE_VERSION} found:"
285+
echo "No unexpected references to previous version ${PREVIOUS_RELEASE_VERSION} found."
278286
exit 0
279287
else
280288
echo "References to previous version ${PREVIOUS_RELEASE_VERSION} found:"
@@ -373,7 +381,7 @@ pipeline {
373381
- Updating the release version to `${NEXT_RELEASE_VERSION}` across build scripts
374382
- Updating the previous release version to the current Release-Candidate: `${PREVIOUS_RELEASE_CANDIDATE_ID}`
375383
""".stripIndent(), prBranch)
376-
384+
377385
def submodulePaths = sh(script: "git submodule --quiet foreach 'echo \$sm_path'", returnStdout: true).trim().split('\\s')
378386
for (submodulePath in submodulePaths) {
379387
def diff = sh(script:"cd ${submodulePath} && git diff master origin/master --shortstat", returnStdout: true).trim()
@@ -469,3 +477,7 @@ def replaceInFile(String filePath, Map<String,String> replacements) {
469477
def replaceAllInFile(String filePath, Map<String,String> replacements) {
470478
utilities.replaceAllInFile(filePath, replacements)
471479
}
480+
481+
def gitCommitAllExcludingSubmodules(String commitMessage) {
482+
utilities.gitCommitAllExcludingSubmodules(commitMessage)
483+
}

JenkinsJobs/Releng/promoteBuild.jenkinsfile

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ pipeline {
99
label 'basic'
1010
}
1111
environment {
12-
HIDE_SITE = 'true'
1312
// Download Server locations (would very seldom change)
1413
EP_ROOT = '/home/data/httpd/download.eclipse.org'
1514
}
@@ -42,16 +41,11 @@ pipeline {
4241
assignEnvVariable('REPO_ID', "I${idMatcher.group('date')}-${idMatcher.group('time')}")
4342
idMatcher = null // release matcher as it's not serializable
4443

45-
sh 'curl -o buildproperties.shsource --fail https://download.eclipse.org/eclipse/downloads/drops4/${DROP_ID}/buildproperties.shsource'
46-
def STREAM = sh(returnStdout: true, script: 'source ./buildproperties.shsource && echo ${STREAM}').trim()
47-
def versionMatcher = STREAM =~ /(?<major>\d+)\.(?<minor>\d+).(?<service>\d+)/
48-
if (!versionMatcher.matches()) {
49-
error "STREAM must contain major, minor, and service versions, such as '4.37.0', but found: ${STREAM}"
50-
}
51-
assignEnvVariable('BUILD_MAJOR', versionMatcher.group('major'))
52-
assignEnvVariable('BUILD_MINOR', versionMatcher.group('minor'))
53-
assignEnvVariable('BUILD_SERVICE', versionMatcher.group('service'))
54-
versionMatcher = null // release matcher as it's not serializable
44+
def buildPropertiesTxt = sh(script: "curl --fail https://download.eclipse.org/eclipse/downloads/drops4/${DROP_ID}/buildproperties.txt", returnStdout: true)
45+
def buildProperties = readProperties(text: buildPropertiesTxt)
46+
assignEnvVariable('BUILD_MAJOR', buildProperties.STREAMMajor.replace('"','')) // Remove surrounding quotes
47+
assignEnvVariable('BUILD_MINOR', buildProperties.STREAMMinor.replace('"','')) // Remove surrounding quotes
48+
assignEnvVariable('BUILD_SERVICE', buildProperties.STREAMService.replace('"','')) // Remove surrounding quotes
5549

5650
if ("${CHECKPOINT}" ==~ /M\d+([a-z])?/ || "${CHECKPOINT}" ==~ /RC\d+([a-z])?/) { // milestone or RC promotion
5751
assignEnvVariable('DL_TYPE', 'S')
@@ -90,9 +84,12 @@ pipeline {
9084
}
9185
sh '''#!/bin/bash -xe
9286
git branch --force master HEAD
93-
git fetch origin "refs/heads/${MAINTENANCE_BRANCH}"
94-
git reflog show master
95-
git reflog show "origin/${MAINTENANCE_BRANCH}"
87+
if [[ "${DL_TYPE}" == 'R' ]]; then
88+
git fetch origin "refs/heads/${MAINTENANCE_BRANCH}"
89+
90+
git reflog show master
91+
git reflog show "origin/${MAINTENANCE_BRANCH}"
92+
fi
9693

9794
git fetch origin tag "${REPO_ID}"
9895
git checkout "${REPO_ID}"
@@ -196,7 +193,7 @@ pipeline {
196193
script { // Update the master branch
197194
sh 'git checkout master'
198195
sh '''
199-
mvn -f eclipse-platform-parent/pom.xml org.eclipse.tycho:tycho-versions-plugin:set-property \
196+
mvn -f eclipse-platform-parent/pom.xml tycho-versions:set-property \
200197
-Dproperties=previous-release.baseline \
201198
-DnewPrevious-release.baseline="${RELEASE_P2_REPOSITORY}"
202199
'''
@@ -225,15 +222,15 @@ pipeline {
225222
'previousReleaseVersionRepo=.*' : "previousReleaseVersionRepo=${BUILD_MAJOR}.${BUILD_MINOR}",
226223
])
227224

228-
utilities.commitAllChangesExcludingSubmodules("Update previous release version to ${BUILD_MAJOR}.${BUILD_MINOR} GA across build scripts")
225+
utilities.gitCommitAllExcludingSubmodules("Update previous release version to ${BUILD_MAJOR}.${BUILD_MINOR} GA across build scripts")
229226
}
230227
script { // Update the maintenance branch
231228
sh 'git checkout -b updateMaintenance "origin/${MAINTENANCE_BRANCH}"'
232-
def ecjManifest = sh(script: "curl https://raw.githubusercontent.com/eclipse-jdt/eclipse.jdt.core/refs/tags/${REPO_ID}/org.eclipse.jdt.core.compiler.batch/META-INF/MANIFEST.MF", returnStdout: true).trim()
229+
def ecjManifest = sh(script: "curl --fail https://raw.githubusercontent.com/eclipse-jdt/eclipse.jdt.core/refs/tags/${REPO_ID}/org.eclipse.jdt.core.compiler.batch/META-INF/MANIFEST.MF", returnStdout: true).trim()
233230
def bundleVersion = readManifest(text: ecjManifest).main['Bundle-Version']
234231
def ecjVersion = bundleVersion.substring(0, bundleVersion.indexOf('.qualifier'))
235232
sh """
236-
mvn -f eclipse-platform-parent/pom.xml org.eclipse.tycho:tycho-versions-plugin:set-property \
233+
mvn -f eclipse-platform-parent/pom.xml tycho-versions:set-property \
237234
-Dproperties=eclipse-sdk-repo,previous-release.baseline,cbi-ecj-version \
238235
-DnewEclipse-sdk-repo="${RELEASE_P2_REPOSITORY}" \
239236
-DnewPrevious-release.baseline="${RELEASE_P2_REPOSITORY}" \
@@ -243,7 +240,7 @@ pipeline {
243240
'ECLIPSE_RUN_REPO="https://download.eclipse.org/eclipse/updates/.*"' : "ECLIPSE_RUN_REPO=\"${RELEASE_P2_REPOSITORY}\"",
244241
])
245242

246-
utilities.commitAllChangesExcludingSubmodules("Update ${MAINTENANCE_BRANCH} branch with release version for ${BUILD_MAJOR}_${BUILD_MINOR}+ changes")
243+
utilities.gitCommitAllExcludingSubmodules("Update ${MAINTENANCE_BRANCH} branch with release version for ${BUILD_MAJOR}_${BUILD_MINOR}+ changes")
247244
}
248245
// Switch back to master for subsequent parts of this pipeline
249246
sh 'git checkout master'
@@ -330,10 +327,9 @@ def renameBuildDrop(String baseDropPath, String oldDropID, String oldBuildLabel,
330327

331328
# Copy drop-directory to new location
332329
ssh [email protected] mkdir -p '${targetPath}'
333-
if [[ "${HIDE_SITE}" == "true" ]]; then
334-
# Create this marker first to ensure the page is never without
335-
ssh [email protected] touch '${targetPath}/buildHidden'
336-
fi
330+
# Create this marker first to ensure the page is never without
331+
ssh [email protected] touch '${targetPath}/buildHidden'
332+
337333
ssh [email protected] cp -r '${sourcePath}/.' '${targetPath}'
338334

339335
# Rename files

JenkinsJobs/shared/githubAPI.groovy

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def setDryRun(boolean isDryRun) {
99
/** Returns a list of all repositories in the specified organization.*/
1010
def listReposOfOrganization(String orga) {
1111
def response = queryGithubAPI('', "orgs/${orga}/repos", null)
12-
if (!(response instanceof List) && (response.errors || (response.status && response.status != 201))) {
12+
if (!(response instanceof List) && isFailed(response, 201)) {
1313
error "Response contains errors:\n${response}"
1414
}
1515
return response
@@ -23,7 +23,7 @@ def createMilestone(String orga, String repo, String msTitle, String msDescripti
2323
echo "In ${orga}/${repo} create milestone: ${msTitle} due on ${msDueDay}"
2424
def params = [title: msTitle, description: msDescription, due_on: "${msDueDay}T23:59:59Z"]
2525
def response = queryGithubAPI('-X POST', "repos/${orga}/${repo}/milestones", params)
26-
if (response?.errors || (response?.status && response.status != 201)) {
26+
if (isFailed(response, 201)) {
2727
if (response.errors && response.errors[0]?.code == 'already_exists') {
2828
echo 'Milestone already exists and is not modified'
2929
// TODO: update milestone in this case: https://docs.github.com/en/rest/issues/milestones?apiVersion=2022-11-28#update-a-milestone
@@ -41,7 +41,7 @@ def createPullRequest(String orgaSlashRepo, String prTitle, String prBody, Strin
4141
echo "In ${orgaSlashRepo} create PR: '${prTitle}' on branch ${headBranch}"
4242
def params = [title: prTitle, body: prBody, head: headBranch, base: baseBranch]
4343
def response = queryGithubAPI('-X POST',"repos/${orgaSlashRepo}/pulls", params)
44-
if (response?.errors || (response?.status && response.status != 201)) {
44+
if (isFailed(response, 201)) {
4545
if (skipExistingPR && response.errors[0]?.message?.contains('pull request already exists')) {
4646
echo "Ignoring failure to create pull request: ${response.errors[0].message}"
4747
return null; // PR already exists and the caller asked to ignore this error
@@ -55,7 +55,7 @@ def triggerWorkflow(String orgaSlashRepo, String workflowId, Map<String, String>
5555
echo "In ${orgaSlashRepo} trigger workflow '${workflowId}' on branch ${referenceBranch} with inputs ${inputs}"
5656
def params = ['ref': referenceBranch, 'inputs': inputs]
5757
def response = queryGithubAPI('-X POST',"repos/${orgaSlashRepo}/actions/workflows/${workflowId}/dispatches", params, true)
58-
if (response?.errors || (response?.status && response.status != 204)) {
58+
if (isFailed(response, 204)) {
5959
error "Response contains errors:\n${response}"
6060
}
6161
}
@@ -88,4 +88,8 @@ def queryGithubAPI(String method, String endpoint, Map<String, Object> queryPara
8888
return readJSON(text: response)
8989
}
9090

91+
private boolean isFailed(Map response, int successCode) {
92+
return response?.errors || (response?.status && response.status?.toInteger() != successCode)
93+
}
94+
9195
return this

JenkinsJobs/shared/utilities.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def replaceAllInFile(String filePath, Map<String,String> replacements) {
1515
writeFile(file:filePath, text: content)
1616
}
1717

18-
def commitAllChangesExcludingSubmodules(String commitMessage) {
18+
def gitCommitAllExcludingSubmodules(String commitMessage) {
1919
withEnv(["COMMIT_MESSAGE=${commitMessage}"]) {
2020
sh '''
2121
#Commit all changes, except for the updated sub-modules here

0 commit comments

Comments
 (0)