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

first build fails because of missing parameter

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      The first automatic job execution of a job created by a "multibranch project" will be triggered without parameters. e.g. the following pipeline will print "null" instead of the default value of MY_PARAM. Subsequent executions will work correctly. This is very unfortunate, as such jobs are typically created for short lived branches, in the most ideal case, no further commits are even made to them - they get merged and vanish again.

      pipeline {
      
        parameters {
          choiceParam(choices: 'AA\nBB', description: 'please select...', name: 'MY_PARAM')
        }  
      
        agent any
        stages {
      
          stage ('test') {
            steps {
                sh "echo ${env.MY_PARAM}"
            }
          }
        }
      }
      

        Attachments

          Issue Links

            Activity

            imod Dominik Bartholdi created issue -
            imod Dominik Bartholdi made changes -
            Field Original Value New Value
            Description when


            The first automatic job execution of a job created by a "multibranch project" will be triggered without parameters. e.g. the following pipeline will print "null" instead of the default value of MY_PARAM. Subsequent executions will work correctly. This is very unfortunate, as such jobs are typically created for short lived branches, in the most ideal case, no further commits are even made to them - they get merged and vanish again.

            {noformat}
            pipeline {

              parameters {
                choiceParam(choices: 'AA\nBB', description: 'please select...', name: 'MY_PARAM')
              }

              agent any
              stages {

                stage ('test') {
                  steps {
                      sh "echo ${env.MY_PARAM}"
                  }
                }
              }
            }
            {noformat}
            The first automatic job execution of a job created by a "multibranch project" will be triggered without parameters. e.g. the following pipeline will print "null" instead of the default value of MY_PARAM. Subsequent executions will work correctly. This is very unfortunate, as such jobs are typically created for short lived branches, in the most ideal case, no further commits are even made to them - they get merged and vanish again.

            {noformat}
            pipeline {

              parameters {
                choiceParam(choices: 'AA\nBB', description: 'please select...', name: 'MY_PARAM')
              }

              agent any
              stages {

                stage ('test') {
                  steps {
                      sh "echo ${env.MY_PARAM}"
                  }
                }
              }
            }
            {noformat}
            Hide
            abayer Andrew Bayer added a comment -

            Try params.PARAM - I think that'll work.

            Show
            abayer Andrew Bayer added a comment - Try params.PARAM - I think that'll work.
            abayer Andrew Bayer made changes -
            Link This issue relates to JENKINS-40241 [ JENKINS-40241 ]
            Hide
            imod Dominik Bartholdi added a comment -

            many thanks, that works!! I try to take some time to enhance the documentation...

            Show
            imod Dominik Bartholdi added a comment - many thanks, that works!! I try to take some time to enhance the documentation...
            imod Dominik Bartholdi made changes -
            Resolution Fixed [ 1 ]
            Status Open [ 1 ] Resolved [ 5 ]
            Hide
            bitwiseman Liam Newman added a comment -

            Bulk closing resolved issues.

            Show
            bitwiseman Liam Newman added a comment - Bulk closing resolved issues.
            bitwiseman Liam Newman made changes -
            Status Resolved [ 5 ] Closed [ 6 ]

              People

              Assignee:
              abayer Andrew Bayer
              Reporter:
              imod Dominik Bartholdi
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: