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
+ }
0 commit comments