Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-28566

Use environment variables in build parameters configuration

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • core
    • None

      When defining parameters for a parameterized build job, it should be possible to use environment varibles in the default, values and description fields, so that different build jobs using the same parameters will pick up the new values after changing the global environment variables in the master's configuration.

          [JENKINS-28566] Use environment variables in build parameters configuration

          David Antliff added a comment -

          I'd like to vote for this issue. In particular, it's useful when creating jobs that will use a default value, but that default value may change over time - e.g. the current mainline release version. As things stand at the moment, each job's default value is literal text, so must be updated individually. If a global environment variable could be used to set the default, then it would only need to be changed in one place.

          David Antliff added a comment - I'd like to vote for this issue. In particular, it's useful when creating jobs that will use a default value, but that default value may change over time - e.g. the current mainline release version. As things stand at the moment, each job's default value is literal text, so must be updated individually. If a global environment variable could be used to set the default, then it would only need to be changed in one place.

          Rainer Montag added a comment -

          At least you can use a global environment variable within a pipeline build parameter definition:

          node() {
             // adds job parameters within jenkinsfile
             properties([
               parameters([
                 stringParam(
                   defaultValue: env.MY_GLOBAL_ENV_VAR,
                   description: '',
                   name: 'my_global_env_var'
                 ),
               ])
             ])   
          
             print 'params.my_global_env_var = ' + params.my_global_env_var
             print "params.my_global_env_var = ${params.my_global_env_var}"
             sh "echo sh params.my_global_env_var is ${params.my_global_env_var}"
          } 

           

          Rainer Montag added a comment - At least you can use a global environment variable within a pipeline build parameter definition: node() { // adds job parameters within jenkinsfile properties([ parameters([ stringParam( defaultValue: env.MY_GLOBAL_ENV_VAR, description: '', name: 'my_global_env_var' ), ]) ]) print 'params.my_global_env_var = ' + params.my_global_env_var print "params.my_global_env_var = ${params.my_global_env_var}" sh "echo sh params.my_global_env_var is ${params.my_global_env_var}" }  

            Unassigned Unassigned
            dhs Dirk Heinrichs
            Votes:
            9 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated: