Description

As a user, I would like to reuse a Jenkinsfile across different Jenkins installations and being capable of setting parameters inside a Jenkinsfile, with default values that are loaded from some other source.

For example:

I have a project that is built on two different Jenkins installations that are running on different environments. For security reasons the environments needs to be separate. Each environment has some differences that I need to set in the parameters, in order to be able to run the job. At the moment I am obligated to use "ifs" based on the env.JOB_NAME in order to change each defaultValue for every parameter.

Not only this, but I also need to use a cron trigger for this pipeline, which forcibly uses the default values to run it.

I've tried many hacks to make the defaults to be loaded from some other place, but they don't play nicely with the way Jenkins constructs the "Build with Parameters" form. The Jenkinsfile is not pre-executed neither pre-loaded in order to construct this form, so even if I find a way to dynamically set the defaultValue for every parameter, this value will not be kept.

So, I believe Jenkins should have one of the following solutions:

A way to preload the Jenkinsfile from the source repository, without having to run through the steps, including running part of the Jenkinsfile to be able to dynamically set default values for the parameters (ex.: getting values from env and using as defaultValue in the preload).

A way to set the defaults that is separate from the Jenkinsfile - could be directly in the job configuration

Attachments

Activity

Herbert Fischer This is a completely reasonable enhancement but please reserve Critical priority for features that are needed to use Pipelines in a standard, common way. For bugs, Critical would be something that brings Jenkins down completely or renders core functionality unusable (i.e. a regression meaning that no Pipelines run, or for an SCM, you can't check out code ever), so keep that in mind. Thanks!

This is a pretty specialized usage you're describing, so I'm adjusting priority accordingly... but also voting for the issue myself because in my Jenkins usage I need default parameter handling and have been annoyed by the need for code hacks to work around it.

Sam Van Oort
added a comment - 2018-04-12 16:15 Herbert Fischer This is a completely reasonable enhancement but please reserve Critical priority for features that are needed to use Pipelines in a standard, common way. For bugs, Critical would be something that brings Jenkins down completely or renders core functionality unusable (i.e. a regression meaning that no Pipelines run, or for an SCM, you can't check out code ever), so keep that in mind. Thanks!
This is a pretty specialized usage you're describing, so I'm adjusting priority accordingly... but also voting for the issue myself because in my Jenkins usage I need default parameter handling and have been annoyed by the need for code hacks to work around it.

Another +1 for this feature, my use case is different but I'd say the usage isn't that specialised: I have a simple build CI/CD pipeline for a F/OSS project however the artifact it builds needs to be uploaded somewhere: for me this is a cloud object store. I do not want to leak object store buckets or paths that are specific to my companies' implementation of this project. I'd like to do it all within the same pipeline but as I can't I'm looking at the workflow plugin instead, simply to do the upload.

Steph Gosling
added a comment - 2018-04-14 15:16 Another +1 for this feature, my use case is different but I'd say the usage isn't that specialised: I have a simple build CI/CD pipeline for a F/OSS project however the artifact it builds needs to be uploaded somewhere: for me this is a cloud object store. I do not want to leak object store buckets or paths that are specific to my companies' implementation of this project. I'd like to do it all within the same pipeline but as I can't I'm looking at the workflow plugin instead, simply to do the upload.

Default values are took from properties file.
Default values can be overriden at UI.
Values at UI are cached from last run.
To restore defaults (from properties file) for next run just delete cached values.