Skip to content

Commit 1216581

Browse files
committed
[Build] Read parameters from Jenkins-files and create jobs dynamically
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 after the pipeline was 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 and 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 drawback 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 creates jobs dynamically 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. This also ensures a unified naming schema of all jobs that corresponds to the name of the pipeline's Jenkinsfile.
1 parent c51fa4f commit 1216581

22 files changed

+384
-432
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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Constants read by
2+
private static final _JOB_DESCRIPTION = 'Build and publish custom Docker images'
3+
14
pipeline {
25
options {
36
skipDefaultCheckout()
@@ -6,6 +9,9 @@ pipeline {
69
buildDiscarder(logRotator(numToKeepStr:'5'))
710
disableConcurrentBuilds(abortPrevious: true)
811
}
12+
triggers {
13+
cron '@weekly'
14+
}
915
agent {
1016
label 'docker-build'
1117
}

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: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1+
// Constants read by
2+
private static final _JOB_DESCRIPTION = 'Mark a build as stable/unstable or to (not to) be kept indefinitely.'
3+
14
pipeline {
25
options {
36
skipDefaultCheckout()
47
timestamps()
58
timeout(time: 5, unit: 'MINUTES')
69
buildDiscarder(logRotator(numToKeepStr:'5'))
710
}
11+
parameters {
12+
string(name: 'buildId', trim: true, description: 'ID of the build to be marked.')
13+
choice(name: 'markAs', choices: [ 'STABLE', 'UNSTABLE', 'RETAINED_INDEFINITELY', 'NOT_RETAINED' ],
14+
description: 'The kind of marker to apply to (respectively remove from) the specified build.')
15+
string(name: 'issueURL', trim: true,
16+
description: 'URL of the causing Github issue or PR (<em>only relevant if the build is marked as unstable<em>).')
17+
}
818
agent {
919
label 'basic'
1020
}
@@ -18,10 +28,6 @@ pipeline {
1828
steps {
1929
sshagent(['projects-storage.eclipse.org-bot-ssh']) {
2030
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-
2531
if [ -z "$buildId" ]; then
2632
echo "BuildId is empty! Exiting."
2733
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)