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

When using build step and a choice parameter plugin it accepts any value

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • Jenkins 1.107.2-Rolling
      pipeline-build-step 2.7 version

      When using build step and a choice parameter plugin it accepts any value. Also, it accepts parameters that are not defined.

      Here we have an example that shows that behavior.

      We need two pipeline jobs:

      Main job:

      stage ('UpstreamJob')\{ 
      build job: 'DownstreamJob', parameters: [ 
      string(name: 'ARTIFACT_NAME', value: "myArtifact_5.5.5.zip"), 
      string(name: 'DEPLOY_PHASE', value: "Production"), 
      string(name: 'DEPLOYMENT_COLOR', value: "purple"), 
      string(name: 'SOMEEXTRAVAR', value: "Woohoo I can do whatever I want!") 
      ] 
      }
      

      And a Downstream Job:

      properties([ 
      parameters([ 
      string( 
      name: 'ARTIFACT_NAME', 
      description: 'Name of the artifact to deploy', 
      defaultValue: 'myArtifact_1.0.zip' 
      ), 
      choice( 
      choices: ["Development"].join("\n"), 
      description: 'Only development is allowed!', 
      name: 'DEPLOY_PHASE'), 
      choice( 
      choices: ["blue", "green"].join("\n"), 
      description: 'Color of Blue/Green deployment option', 
      name: 'DEPLOYMENT_COLOR') 
      ]) 
      ])
      
      UserInput = "User Supplied Values:\n" 
      params.each\{ 
      k, v -> UserInput = UserInput + """ $\{k}\n $\{v}\n""" 
      }
      
      echo UserInput
      
      stage ('DownstreamJob')\{ 
      
      echo "The value of SOMEEXTRAVAR: $SOMEEXTRAVAR" 
      
      }
      

      When executing the main job the result is:

      User Supplied Values: DEPLOYMENT_COLOR purple DEPLOY_PHASE Production SOMEEXTRAVAR Woohoo I can do whatever I want! ARTIFACT_NAME myArtifact_5.5.5.zip [Pipeline] stage [Pipeline] \{ (DownstreamJob) [Pipeline] } [Pipeline] // stage [Pipeline] End of Pipeline groovy.lang.MissingPropertyException: No such property: SOMEEXTRAVAR for class: groovy.lang.Binding at groovy.lang.Binding.getVariable(Binding.java:63) at 
      

      Here we see that the choice value accepts values that are not defined and also the "SOMEEXTRAVAR" that is not a parameter has accepted that value perhaps after executing that step the pipeline build failed telling that there is no valid value for that variable

       

          [JENKINS-52038] When using build step and a choice parameter plugin it accepts any value

          Andrew Bayer added a comment -

          Andrew Bayer added a comment - PR up at https://github.com/jenkinsci/pipeline-build-step-plugin/pull/23

          Andrew Bayer added a comment -

          Releasing as Pipeline Input Step plugin 2.9.

          Andrew Bayer added a comment - Releasing as Pipeline Input Step plugin 2.9.

            abayer Andrew Bayer
            jraezrus Javier Raez
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: