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

input directive is not respecting when condition

    Details

    • Similar Issues:

      Description

      In a descriptive pipeline I would like to have a user input directive that is only active for a certain branch:

      pipeline{
          agent none
          stages {
              stage ('build') {
                  agent any
                  when { anyOf { branch 'master'; branch 'PR-*' } }
                  steps {echo "build done"}
              }
              stage ('release') {
                  agent any
                  when { branch 'master'}
                  input {message 'Do you want to publish a new release?'}
                  steps {echo "release done"}
              }
          }
       }
      

      Currently the input is raised but the stage is then skipped.

      This could be done with a dedicated stage and the input step, but I would like to use the coding above.

      The beforeAgent options seems not to do the trick.

      when {
        beforeAgent true
        branch 'master'
      }
      

        Attachments

          Issue Links

            Activity

            ennef Christopher Fenner created issue -
            ennef Christopher Fenner made changes -
            Field Original Value New Value
            Description In a pipeline I would like to have a user input directive that is only active for a certain branch:

            {code:java}
            pipeline{
                agent none
                stages {
                    stage ('build') {
                        agent any
                        when { anyOf { branch 'master'; branch 'PR-*' } }
                        steps {echo "build done"}
                    }
                    stage ('release') {
                        agent any
                        when { branch 'master'}
                        input {message 'Do you want to publish a new release?'}
                        steps {echo "release done"}
                    }
                }
             }
            {code}

            This could be done with a dedicated stage and the input *step*, but I would like to use the coding above.
            In a pipeline I would like to have a user input directive that is only active for a certain branch:

            {code:groovy}
            pipeline{
                agent none
                stages {
                    stage ('build') {
                        agent any
                        when { anyOf { branch 'master'; branch 'PR-*' } }
                        steps {echo "build done"}
                    }
                    stage ('release') {
                        agent any
                        when { branch 'master'}
                        input {message 'Do you want to publish a new release?'}
                        steps {echo "release done"}
                    }
                }
             }
            {code}

            This could be done with a dedicated stage and the input *step*, but I would like to use the coding above.

            The *beforeAgent* options seems not to do the trick.

            {code:groovy}
            when {
              beforeAgent true
              branch 'master'
            }
            {code}
             
            ennef Christopher Fenner made changes -
            Description In a pipeline I would like to have a user input directive that is only active for a certain branch:

            {code:groovy}
            pipeline{
                agent none
                stages {
                    stage ('build') {
                        agent any
                        when { anyOf { branch 'master'; branch 'PR-*' } }
                        steps {echo "build done"}
                    }
                    stage ('release') {
                        agent any
                        when { branch 'master'}
                        input {message 'Do you want to publish a new release?'}
                        steps {echo "release done"}
                    }
                }
             }
            {code}

            This could be done with a dedicated stage and the input *step*, but I would like to use the coding above.

            The *beforeAgent* options seems not to do the trick.

            {code:groovy}
            when {
              beforeAgent true
              branch 'master'
            }
            {code}
             
            In a descriptive pipeline I would like to have a user input directive that is only active for a certain branch:
            {code}
            pipeline{
                agent none
                stages {
                    stage ('build') {
                        agent any
                        when { anyOf { branch 'master'; branch 'PR-*' } }
                        steps {echo "build done"}
                    }
                    stage ('release') {
                        agent any
                        when { branch 'master'}
                        input {message 'Do you want to publish a new release?'}
                        steps {echo "release done"}
                    }
                }
             }
            {code}
            This could be done with a dedicated stage and the input *step*, but I would like to use the coding above.

            The *beforeAgent* options seems not to do the trick.
            {code}
            when {
              beforeAgent true
              branch 'master'
            }
            {code}
            ennef Christopher Fenner made changes -
            Description In a descriptive pipeline I would like to have a user input directive that is only active for a certain branch:
            {code}
            pipeline{
                agent none
                stages {
                    stage ('build') {
                        agent any
                        when { anyOf { branch 'master'; branch 'PR-*' } }
                        steps {echo "build done"}
                    }
                    stage ('release') {
                        agent any
                        when { branch 'master'}
                        input {message 'Do you want to publish a new release?'}
                        steps {echo "release done"}
                    }
                }
             }
            {code}
            This could be done with a dedicated stage and the input *step*, but I would like to use the coding above.

            The *beforeAgent* options seems not to do the trick.
            {code}
            when {
              beforeAgent true
              branch 'master'
            }
            {code}
            In a descriptive pipeline I would like to have a user input directive that is only active for a certain branch:
            {code:java}
            pipeline{
                agent none
                stages {
                    stage ('build') {
                        agent any
                        when { anyOf { branch 'master'; branch 'PR-*' } }
                        steps {echo "build done"}
                    }
                    stage ('release') {
                        agent any
                        when { branch 'master'}
                        input {message 'Do you want to publish a new release?'}
                        steps {echo "release done"}
                    }
                }
             }
            {code}
            Currently the input is raised but the stage is then skipped.

             

             

            This could be done with a dedicated stage and the input *step*, but I would like to use the coding above.

            The *beforeAgent* options seems not to do the trick.
            {code:java}
            when {
              beforeAgent true
              branch 'master'
            }
            {code}
            ennef Christopher Fenner made changes -
            Description In a descriptive pipeline I would like to have a user input directive that is only active for a certain branch:
            {code:java}
            pipeline{
                agent none
                stages {
                    stage ('build') {
                        agent any
                        when { anyOf { branch 'master'; branch 'PR-*' } }
                        steps {echo "build done"}
                    }
                    stage ('release') {
                        agent any
                        when { branch 'master'}
                        input {message 'Do you want to publish a new release?'}
                        steps {echo "release done"}
                    }
                }
             }
            {code}
            Currently the input is raised but the stage is then skipped.

             

             

            This could be done with a dedicated stage and the input *step*, but I would like to use the coding above.

            The *beforeAgent* options seems not to do the trick.
            {code:java}
            when {
              beforeAgent true
              branch 'master'
            }
            {code}
            In a descriptive pipeline I would like to have a user input directive that is only active for a certain branch:
            {code:java}
            pipeline{
                agent none
                stages {
                    stage ('build') {
                        agent any
                        when { anyOf { branch 'master'; branch 'PR-*' } }
                        steps {echo "build done"}
                    }
                    stage ('release') {
                        agent any
                        when { branch 'master'}
                        input {message 'Do you want to publish a new release?'}
                        steps {echo "release done"}
                    }
                }
             }
            {code}
            Currently the input is raised but the stage is then skipped.


            This could be done with a dedicated stage and the input *step*, but I would like to use the coding above.

            The *beforeAgent* options seems not to do the trick.
            {code:java}
            when {
              beforeAgent true
              branch 'master'
            }
            {code}
            ennef Christopher Fenner made changes -
            Description In a descriptive pipeline I would like to have a user input directive that is only active for a certain branch:
            {code:java}
            pipeline{
                agent none
                stages {
                    stage ('build') {
                        agent any
                        when { anyOf { branch 'master'; branch 'PR-*' } }
                        steps {echo "build done"}
                    }
                    stage ('release') {
                        agent any
                        when { branch 'master'}
                        input {message 'Do you want to publish a new release?'}
                        steps {echo "release done"}
                    }
                }
             }
            {code}
            Currently the input is raised but the stage is then skipped.


            This could be done with a dedicated stage and the input *step*, but I would like to use the coding above.

            The *beforeAgent* options seems not to do the trick.
            {code:java}
            when {
              beforeAgent true
              branch 'master'
            }
            {code}
            In a descriptive pipeline I would like to have a user input directive that is only active for a certain branch:
            {code:java}
            pipeline{
                agent none
                stages {
                    stage ('build') {
                        agent any
                        when { anyOf { branch 'master'; branch 'PR-*' } }
                        steps {echo "build done"}
                    }
                    stage ('release') {
                        agent any
                        when { branch 'master'}
                        input {message 'Do you want to publish a new release?'}
                        steps {echo "release done"}
                    }
                }
             }
            {code}
            Currently the input is raised but the stage is then skipped.



            This could be done with a dedicated stage and the input *step*, but I would like to use the coding above.

            The *beforeAgent* options seems not to do the trick.
            {code:java}
            when {
              beforeAgent true
              branch 'master'
            }
            {code}
            ennef Christopher Fenner made changes -
            Link This issue duplicates JENKINS-50880 [ JENKINS-50880 ]
            ennef Christopher Fenner made changes -
            Status Open [ 1 ] Closed [ 6 ]
            Resolution Duplicate [ 3 ]

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                ennef Christopher Fenner
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: