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

          Javier Raez created issue -
          jang hyemi (Inactive) made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Andrew Bayer made changes -
          Assignee New: Andrew Bayer [ abayer ]
          Andrew Bayer made changes -
          Status Original: In Progress [ 3 ] New: In Review [ 10005 ]

          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 made changes -
          Remote Link New: This issue links to "PR #23 (Web Link)" [ 22592 ]

          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.
          Andrew Bayer made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: In Review [ 10005 ] New: Resolved [ 5 ]
          Nick Jones made changes -
          Description Original: {{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 DownstreamJob:

           

          ````

          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}}

           
          New: 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:

          {code:java}
          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!")

          }
          {code}

          And a Downstream Job:

          {code:java}
          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" 

          }
          {code}

          When executing the main job the result is:

          {noformat}
          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
          {noformat}


          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

           

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

              Created:
              Updated:
              Resolved: