Skip to content

Commit a6cfaee

Browse files
committed
[Build] Refine check for SWT native binary rebuild commit
Currently the build is aborted if the branch tip is at a commit, which was committed with the email of the 'Eclipse Platform Bot'. This is done to prevent rebuilds after a commit for a SWT native binary rebuild was pushed by the bot. But because that bot is also used for other kind of commits, this test leads to false positives. This reworks the pipeline to check if the head commit has a SWT-native-binary build tag attached, which is a more precise indicator. This also fixes the check if a native rebuild is enforced, when testing if the build can be skipped.
1 parent b0bacb3 commit a6cfaee

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

Jenkinsfile

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def runOnNativeBuildAgent(String platform, Closure body) {
4242
}
4343
}
4444

45+
4546
/** Returns the download URL of the JDK against whose C headers (in the 'include/' folder) and native libraries the SWT natives are compiled.*/
4647
def getNativeJdkUrl(String os, String arch) { // To update the used JDK version update the URL template below
4748
if ('win32'.equals(os) && 'aarch64'.equals(arch)) {
@@ -70,8 +71,10 @@ def getNativeJdkUrl(String os, String arch) { // To update the used JDK version
7071
return "https://download.eclipse.org/justj/jres/17/downloads/20230428_1804/org.eclipse.justj.openjdk.hotspot.jre.minimal.stripped-17.0.7-${os}-${arch}.tar.gz"
7172
}
7273

74+
nativeBinariesTagPattern = 'v[0-9][0-9][0-9][0-9]r*'
75+
7376
def getLatestGitTag() {
74-
return sh(script: 'git describe --abbrev=0 --tags --match v[0-9][0-9][0-9][0-9]*', returnStdout: true).trim()
77+
return sh(script: "git describe --abbrev=0 --tags --match ${nativeBinariesTagPattern}", returnStdout: true).trim()
7578
}
7679

7780
def getSWTVersions() { // must be called from the repository root
@@ -114,26 +117,24 @@ pipeline {
114117
dir('eclipse.platform.swt') {
115118
checkout scm
116119
script {
117-
def authorMail = sh(script: 'git log -1 --pretty=format:"%ce" HEAD', returnStdout: true)
118-
echo 'HEAD commit author: ' + authorMail
119-
def buildBotMail = '[email protected]'
120-
if (buildBotMail.equals(authorMail) && !params.forceNativeBuilds) {
121-
// Prevent endless build-loops due to self triggering because of a previous automated build of natives and the associated updates.
122-
currentBuild.result = 'ABORTED'
123-
error('Abort build only triggered by automated SWT-natives update.')
124-
}
125-
sh """
120+
sh '''
126121
java -version
127122
git version
128123
git lfs version
129-
git config --global user.email '${buildBotMail}'
124+
git config --global user.email '[email protected]'
130125
git config --global user.name 'Eclipse Platform Bot'
131126
git config --unset core.hooksPath # Jenkins disables hooks by default as security feature, but we need the hooks for LFS
132127
git lfs update # Install Git LFS hooks in repository, which has been skipped due to the initially nulled hookspath
133128
git lfs pull
134129
git fetch --all --tags --quiet
135130
git remote set-url --push origin [email protected]:eclipse-platform/eclipse.platform.swt.git
136-
"""
131+
'''
132+
def launcherTagsAtCommit = sh(script: "git tag --points-at HEAD --list '${nativeBinariesTagPattern}'", returnStdout: true).trim()
133+
if (!launcherTagsAtCommit.isEmpty() && !params.any{ e -> e.key.startsWith('forceNativeBuilds-') && e.value }) {
134+
// Prevent endless build-loops due to self triggering because of a previous automated build of natives and the associated updates.
135+
currentBuild.result = 'ABORTED'
136+
error('Abort build only triggered by automated SWT-natives update.')
137+
}
137138
}
138139
}
139140
}

0 commit comments

Comments
 (0)