Skip to content

Commit 64fe67e

Browse files
committed
[RelEng] Skip already existing build update PR in release promotion
Follow-up on: - eclipse-platform#3291
1 parent f94f68b commit 64fe67e

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

JenkinsJobs/Releng/promoteBuild.jenkinsfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ pipeline {
272272
Update the the `${MAINTENANCE_BRANCH}` branch with final ${BUILD_MAJOR}.${BUILD_MINOR} release version.
273273

274274
**This should not be submitted before ${BUILD_MAJOR}.${BUILD_MINOR} is finally released.**
275-
""".stripIndent(),"update-build-to-R${BUILD_MAJOR}.${BUILD_MINOR}", 'master')
275+
""".stripIndent(),"update-build-to-R${BUILD_MAJOR}.${BUILD_MINOR}", 'master', /*skipExistingPR*/ true)
276276

277277
githubAPI.createPullRequest('eclipse-platform/eclipse.platform.releng.aggregator',
278278
"Update ${MAINTENANCE_BRANCH} branch with release version for ${BUILD_MAJOR}_${BUILD_MINOR}+ changes", """\
@@ -281,7 +281,7 @@ pipeline {
281281
- ${masterPR}
282282

283283
**This should not be submitted before ${BUILD_MAJOR}.${BUILD_MINOR} is finally released.**
284-
""".stripIndent(),"update-${MAINTENANCE_BRANCH}", "${MAINTENANCE_BRANCH}")
284+
""".stripIndent(),"update-${MAINTENANCE_BRANCH}", "${MAINTENANCE_BRANCH}", /*skipExistingPR*/ true)
285285
}}
286286
}
287287
}

JenkinsJobs/shared/githubAPI.groovy

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,15 @@ def createMilestone(String orga, String repo, String msTitle, String msDescripti
3737
/**
3838
* Create a PR in the specified repo, from a branch that is expected to reside in the same repository.
3939
*/
40-
def createPullRequest(String orgaSlashRepo, String prTitle, String prBody, String headBranch, String baseBranch = 'master') {
40+
def createPullRequest(String orgaSlashRepo, String prTitle, String prBody, String headBranch, String baseBranch = 'master', boolean skipExistingPR = false) {
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)
4444
if (response?.errors || (response?.status && response.status != 201)) {
45+
if (skipExistingPR && response.errors[0]?.message?.contains('pull request already exists')) {
46+
echo "Ignoring failure to create pull request: ${response.errors[0].message}"
47+
return null; // PR already exists and the caller asked to ignore this error
48+
}
4549
error "Response contains errors:\n${response}"
4650
}
4751
return response?.html_url

0 commit comments

Comments
 (0)