Skip to content

Conversation

HannesWell
Copy link
Member

@HannesWell HannesWell commented Oct 1, 2025

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:

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.

@HannesWell
Copy link
Member Author

I have already created the new seed job from my fork:

It currently only exists for testing and I'll rename it when it's ready to replace the existing Create Jobs job (but without space in the name).

At the moment this lacks the approval of numerous methods for the RelEng JIPP as requested in:

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.

TODO: make sure to rename jobs in advance if their name has changed
@HannesWell HannesWell force-pushed the read-job-parameters-from-pipeline branch from c369f00 to bbe8ec8 Compare October 1, 2025 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant