jenkinsci / jenkinsci/workflow-aggregator-plugin

[JENKINS-46542] External way to set default parameter values for a pipeline job

Open
#802 9 comments 0 reactions 0 assignees View on GitHub
component:pipeline imported-jira-issue jira-type:story pipeline priority:minor resolution:unresolved
Dominant language
No language data
Stars
225
Forks
125
PR merge metrics
No merged PRs in 30d

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

---
Originally reported by hgfxng, imported from: External way to set default parameter values for a pipeline job


  • status: Open
  • priority: Minor
  • component(s): pipeline
  • label(s): Jenkinsfile, env, envinject, jenkins, parameterized, parameters, pipeline
  • resolution: Unresolved
  • votes: 14
  • watchers: 18
  • imported: 2025-12-08

Raw content of original issue

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


  • environment: latest Jenkins and plugins as of the date when this ticket was created - OS is irrelevant

Contributor guide

Open the contributing guide

Research direction

Start with the Jenkinsfile parameter declarations and the Build with Parameters form behavior described in the issue, then trace how cron-triggered builds obtain default values. Compare the proposed preload and job-configuration approaches; done requires an agreed design and a working way to supply installation-specific defaults without conditionals in the Jenkinsfile.

Written by the indexing model from the issue text.

Assessment

Domain
ci-cd
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.