Skip to content

Commit ceabfa7

Browse files
committed
[Build] Read parameters from Jenkins-files
When creating a pipeline-job the Jenkins JobDSL, by default, doesn't consider the parameters defined within the pipeline-job's Jenkinsfile. Therefore parameters defined only within the Jenkinsfile are only added to the job's definition when the pipeline is executed first (and updated on subsequent executions, if changes are applied). In order to make parameters available even on the first run, instead they have to be defined in the groovy-file that uses the Jenkins Job-DSL to define the pipeline-job. This is an long standing, known, yet unsolved issue in Jenkins: - https://issues.jenkins.io/browse/JENKINS-41929 The current solution to define parameters in the job-definition has the consequence that an important part of the pipeline is defined in another file, which makes maintenance more difficult. This implements an enhanced work-around, allowing to define the parameters within a pipeline's Jenkinsfile again: During the definition of a pipeline-job, it's Jenkinsfile file is parsed and its AST is searched for parameter definitions. All encountered parameters are translated dynamically into corresponding parameters of the job definition. With this new possibility all parameters have their definition moved into their pipeline's Jenkinsfile. Furthermore this adds a JenkinsFile for the seedJob of the RelEng JIPP, which was previously manually defined as a free-style job. That seedJob pipeline also dynamically created jobs from all pipeline files in the corresponding folders. It's therefore sufficient to just add a JenkinsFile and not necessary anymore to explicitly add a corresponding pipeline job definition anywhere.
1 parent e721e1f commit ceabfa7

22 files changed

+364
-401
lines changed

JenkinsJobs/AutomatedTests/FOLDER.groovy

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

JenkinsJobs/AutomatedTests/I_unit_tests.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
def config = new groovy.json.JsonSlurper().parseText(readFileFromWorkspace('JenkinsJobs/JobDSL.json'))
1+
def config = new groovy.json.JsonSlurper().parseText(readFileFromWorkspace('JobDSL.json'))
22

33
def TEST_CONFIGURATIONS = [
44
[os: 'linux' , ws:'gtk' , arch: 'x86_64' , javaVersion: 21, agentLabel: 'ubuntu-2404' , javaHome: "tool(type:'jdk', name:'temurin-jdk21-latest')" ],

JenkinsJobs/Builds/DockerImagesBuild.jenkinsfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ pipeline {
66
buildDiscarder(logRotator(numToKeepStr:'5'))
77
disableConcurrentBuilds(abortPrevious: true)
88
}
9+
triggers {
10+
cron '@weekly'
11+
}
912
agent {
1013
label 'docker-build'
1114
}

JenkinsJobs/Builds/FOLDER.groovy

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

JenkinsJobs/Builds/build.jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ spec:
303303
]
304304
}
305305
}
306-
build job: 'SmokeTests/Start-smoke-tests', wait: false, parameters: [string(name: 'buildId', value: "${BUILD_IID}")]
306+
build job: 'SmokeTests/StartSmokeTests', wait: false, parameters: [string(name: 'buildId', value: "${BUILD_IID}")]
307307
}
308308
}
309309
stage('Trigger publication to Maven snapshots repo') {

JenkinsJobs/Builds/markBuild.jenkinsfile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
1+
// Constants read by
2+
//TODO: Remove this name as it can be derived from the file name
3+
private static final _JOB_DESCRIPTION = 'Mark a build as stable/unstable or to (not to) be kept indefinitely.'
4+
15
pipeline {
26
options {
37
skipDefaultCheckout()
48
timestamps()
59
timeout(time: 5, unit: 'MINUTES')
610
buildDiscarder(logRotator(numToKeepStr:'5'))
711
}
12+
parameters {
13+
string(name: 'buildId', trim: true, description: 'ID of the build to be marked.')
14+
choice(name: 'markAs', choices: [ 'STABLE', 'UNSTABLE', 'RETAINED_INDEFINITELY', 'NOT_RETAINED' ],
15+
description: 'The kind of marker to apply to (respectively remove from) the specified build.')
16+
string(name: 'issueURL', trim: true,
17+
description: 'URL of the causing Github issue or PR (<em>only relevant if the build is marked as unstable<em>).')
18+
booleanParam(name: 'DEBUG_BUILD', defaultValue: true, description: '')
19+
}
820
agent {
921
label 'basic'
1022
}
@@ -18,10 +30,6 @@ pipeline {
1830
steps {
1931
sshagent(['projects-storage.eclipse.org-bot-ssh']) {
2032
sh '''#!/bin/bash -xe
21-
# Strip spaces from the buildId and eclipseStream
22-
buildId=$(echo $buildId|tr -d ' ')
23-
issueURL=$(echo $issueURL|tr -d ' ')
24-
2533
if [ -z "$buildId" ]; then
2634
echo "BuildId is empty! Exiting."
2735
exit 1

JenkinsJobs/Cleanup/FOLDER.groovy

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

JenkinsJobs/Cleanup/cleanupBuilds.jenkinsfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Constants read by job creation
2+
private static final _JOB_DISPLAY_NAME = 'Daily Cleanup of old Builds'
3+
private static final _JOB_DESCRIPTION = 'Remove old builds from the downloads servers.'
14

25
def int EQUINOX_RETENTION_COUNT = 3 // Keep the three most recent builds
36
def int ECLIPSE_I_BUILD_RETENTION_DAYS = 5 // Minimal number of days for which a drop should be retained
@@ -11,6 +14,12 @@ pipeline {
1114
timeout(time: 15, unit: 'MINUTES')
1215
buildDiscarder(logRotator(numToKeepStr:'5'))
1316
}
17+
triggers {
18+
cron '''TZ=America/Toronto
19+
0 4 * * *
20+
0 16 * * *
21+
'''
22+
}
1423
agent {
1524
label 'basic'
1625
}

JenkinsJobs/Cleanup/cleanupReleaseArtifacts.jenkinsfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Constants read by job creation
2+
private static final _JOB_DESCRIPTION = 'Cleanup major artifacts from previous releases at the beginning of a new release.'
3+
14
def int RELEASE_RETENTION_COUNT = 3
25

36
pipeline {

0 commit comments

Comments
 (0)