Skip to content

Commit 449f30f

Browse files
committed
[Build] Unify marking and update-index jobs and convert to pipeline
Furthermore derive the issue label from the 'issueURLissueNum, which allows to remove the separate 'issueNum' parameter.
1 parent 73e6651 commit 449f30f

File tree

4 files changed

+149
-234
lines changed

4 files changed

+149
-234
lines changed

JenkinsJobs/Builds/markBuild.groovy

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
for (marker in [ 'stable', 'unstable' ]) {
2+
pipelineJob("Builds/mark${marker.capitalize()}"){
3+
displayName("Mark ${marker.capitalize()}")
4+
description("Mark a build as ${marker}.")
5+
parameters {
6+
stringParam('buildId', null, "ID of the build to be marked ${marker}.")
7+
if(marker == 'unstable') {
8+
stringParam('issueUrl', null, 'URL of the causing Github issue or PR.')
9+
}
10+
}
11+
definition {
12+
cps {
13+
sandbox()
14+
script('''\
15+
pipeline {
16+
options {
17+
timestamps()
18+
buildDiscarder(logRotator(numToKeepStr:'5'))
19+
}
20+
agent {
21+
label 'basic'
22+
}
23+
stages {
24+
stage('Update index'){
25+
steps { // workspace is not always cleaned by default. Clean before custom tools are installed into workspace.
26+
sshagent(['projects-storage.eclipse.org-bot-ssh']) {
27+
sh \'''#!/bin/bash -xe
28+
# this function executes command passed as command line parameter and
29+
# if that command fails it exit with the same error code as the failed command
30+
31+
# Strip spaces from the buildId and eclipseStream
32+
buildId=$(echo $buildId|tr -d ' ')
33+
issueUrl=$(echo $issueUrl|tr -d ' ')
34+
35+
if [ -z "$buildId" ]; then
36+
echo "BuildId is empty! Exiting."
37+
exit 1
38+
fi''' + (marker == 'unstable' ? '''
39+
if [ -z $issueUrl ]; then
40+
echo "IssueUrl is empty! Exiting."
41+
exit 1
42+
fi''' : '') + '''
43+
44+
epDownloadDir=/home/data/httpd/download.eclipse.org/eclipse
45+
dropsPath=${epDownloadDir}/downloads/drops4
46+
p2RepoPath=${epDownloadDir}/updates
47+
buildDir=${dropsPath}/${buildId}
48+
49+
workingDir=${epDownloadDir}/workingDir
50+
51+
workspace=${workingDir}/${JOB_NAME}-${BUILD_NUMBER}
52+
53+
ssh [email protected] rm -rf ${workingDir}/${JOB_NAME}*
54+
55+
ssh [email protected] mkdir -p ${workspace}
56+
ssh [email protected] cd ${workspace}
57+
58+
#get latest Eclipse platform product
59+
epRelDir=$(ssh [email protected] ls -d --format=single-column ${dropsPath}/R-*|sort|tail -1)
60+
ssh [email protected] tar -C ${workspace} -xzf ${epRelDir}/eclipse-platform-*-linux-gtk-x86_64.tar.gz
61+
62+
#get requisite tools
63+
markingScriptName=\'''' + { switch (marker) {
64+
case 'stable': return 'addToComposite'
65+
case 'unstable': return 'removeFromComposite'
66+
default : throw new IllegalArgumentException("Unknown marker: ${marker}")
67+
} }() + ''''
68+
ssh [email protected] wget -O ${workspace}/${markingScriptName}.xml https://download.eclipse.org/eclipse/relengScripts/cje-production/scripts/${markingScriptName}.xml
69+
70+
#triggering ant runner
71+
baseBuilderDir=${workspace}/eclipse
72+
javaCMD=/opt/public/common/java/openjdk/jdk-17_x64-latest/bin/java
73+
74+
launcherJar=$(ssh [email protected] find ${baseBuilderDir}/. -name "org.eclipse.equinox.launcher_*.jar" | sort | head -1 )
75+
76+
scp [email protected]:${buildDir}/buildproperties.shsource .
77+
source ./buildproperties.shsource
78+
repoDir=/home/data/httpd/download.eclipse.org/eclipse/updates/${STREAMMajor}.${STREAMMinor}-${BUILD_TYPE}-builds
79+
80+
devworkspace=${workspace}/workspace-antRunner
81+
devArgs=-Xmx512m
82+
extraArgs="${markingScriptName} -Drepodir=${repoDir} -Dcomplocation=${buildId}"
83+
ssh [email protected] ${javaCMD} -jar ${launcherJar} -nosplash -consolelog -debug -data $devworkspace \\
84+
-application org.eclipse.ant.core.antRunner -file ${workspace}/${markingScriptName}.xml ${extraArgs} -vmargs $devArgs
85+
''' + { switch (marker) {
86+
case 'stable': return '''
87+
#Remove hidden attribute and unstable tags
88+
ssh [email protected] rm -f ${buildDir}/buildHidden
89+
ssh [email protected] rm -f ${buildDir}/buildUnstable
90+
'''
91+
case 'unstable': return '''
92+
# Convert URL of GH issue or PR into: 'organization/repository#number'
93+
label=$(echo "${issueUrl##'https://github.com/'}" | sed 's/\\\\/issues\\\\//#/g' | sed 's/\\\\/pull\\\\//#/g')
94+
#add unstable tags
95+
ssh [email protected] rm -f ${buildDir}/buildUnstable
96+
echo "<p>This build is marked unstable due to <a href='${issueUrl}'>${label}</a>.</p>" > buildUnstable
97+
scp buildUnstable [email protected]:${buildDir}/buildUnstable
98+
'''
99+
default : throw new IllegalArgumentException("Unknown marker: ${marker}")
100+
} }() + '''
101+
ssh [email protected] rm -rf ${workingDir}/${JOB_NAME}*
102+
\'''
103+
build job: 'Releng/updateIndex', wait: false
104+
}
105+
}
106+
}
107+
}
108+
}
109+
''')
110+
}
111+
}
112+
}
113+
}

JenkinsJobs/Builds/markStable.groovy

Lines changed: 0 additions & 95 deletions
This file was deleted.

JenkinsJobs/Builds/markUnstable.groovy

Lines changed: 0 additions & 102 deletions
This file was deleted.

JenkinsJobs/Releng/updateIndex.groovy

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,37 @@
1-
job('Releng/updateIndex'){
2-
displayName('Update Download Index')
3-
description('This is a Job for recreating the download indexes.')
4-
5-
logRotator {
6-
numToKeep(10)
7-
}
8-
9-
jdk('openjdk-jdk11-latest')
10-
11-
label('basic')
12-
13-
wrappers { //adds pre/post actions
14-
timestamps()
15-
sshAgent('projects-storage.eclipse.org-bot-ssh')
16-
}
17-
18-
steps {
19-
shell('''
20-
#!/bin/bash -x
21-
22-
PHP_PAGE="createIndex4x.php"
23-
HTML_PAGE="index.html"
24-
TEMP_INDEX="tempIndex.html"
25-
SITE_HOST=${SITE_HOST:-download.eclipse.org}
26-
27-
wget --no-verbose -O ${TEMP_INDEX} https://${SITE_HOST}/eclipse/downloads/${PHP_PAGE} 2>&1
28-
29-
scp ${TEMP_INDEX} [email protected]:/home/data/httpd/download.eclipse.org/eclipse/downloads/${HTML_PAGE}
30-
''')
31-
}
32-
33-
publishers {
34-
extendedEmail {
35-
recipientList("[email protected]")
36-
}
37-
}
1+
pipelineJob('Releng/updateIndex'){
2+
displayName('Update Download Index')
3+
description('This is a Job for recreating the download index.')
4+
definition {
5+
cps {
6+
sandbox()
7+
script('''
8+
pipeline {
9+
options {
10+
timestamps()
11+
buildDiscarder(logRotator(numToKeepStr:'10'))
12+
}
13+
agent {
14+
label 'basic'
15+
}
16+
stages {
17+
stage('Update index'){
18+
steps { // workspace is not always cleaned by default. Clean before custom tools are installed into workspace.
19+
sshagent(['projects-storage.eclipse.org-bot-ssh']) {
20+
sh \'''#!/bin/bash -xe
21+
PHP_PAGE="createIndex4x.php"
22+
HTML_PAGE="index.html"
23+
TEMP_INDEX="tempIndex.html"
24+
25+
wget --no-verbose -O ${TEMP_INDEX} https://download.eclipse.org/eclipse/downloads/${PHP_PAGE} 2>&1
26+
27+
scp ${TEMP_INDEX} [email protected]:/home/data/httpd/download.eclipse.org/eclipse/downloads/${HTML_PAGE}
28+
\'''
29+
}
30+
}
31+
}
32+
}
33+
}
34+
''')
35+
}
36+
}
3837
}

0 commit comments

Comments
 (0)