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

Parameters default to last ones provided in UI, instead of the one provided inside the Jenkinsfile


    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • blueocean-plugin
    • Blue Ocean - Candidates

      Given a Jenkinsfile with a parameters block in it, it's possible to have parameters with default settings defined. When a run is started, the user will be shown the parameters, and given the chance to change them. In the Classic UI, the default value is always set to whatever is in the Jenkinsfile. But in Blue Ocean, the default value is set to whatever the user attempted previously.

      100% of the time.

      Steps to recreate:
      1. Create a Jenkinsfile in a remote repository, with a parameters section defined. In this, use a string parameter to define the agent label on which you want the Pipeline to run. In my case, this is linux, and I have a remote agent connected with that label assigned:

          parameters {
              string(name: 'String parameter with spaces', defaultValue: 'Fill me in with something witty!', description: 'This is a string parameter, yo!')
              booleanParam(name: 'TRUE_OR_FALSE', defaultValue: true, description: 'This boolean defaults to true!') 
              string(name: 'AGENT_NAME', defaultValue: 'linux', description: 'Where to run')

      2. Because of JENKINS-41929, you will need to have run, and then canceled, this Pipeline at least once. Otherwise it'll try to run on an agent of label null, and we know that won't work.

      3. In the Classic UI, when you run this Pipeline, the screen will look like this. It's here that you can change that AGENT_NAME to whatever you like.

      4. Here's the same screen in Blue Ocean, and I've set AGENT_NAME to the value bogus_thing. This won't work, and that's fine.

      5. Click Run, and monitor the build. You'll eventually want to cancel this run, since there's no such agent. This is also fine.

      6. After stopping the ill-fated run you kicked off in step 5, click the Run triangle again. This is the issue: notice that the AGENT_NAME label is set to what you previously changed it to. It should say linux, which is what's in the Jenkinsfile:

      7. This behavior feels incorrect for a couple of reasons. Mostly, because it's not really honoring the default setting you've provided in the Jenkinsfile. Secondarily, the Classic UI always defaults to whatever the Jenkinsfile says. Same exact steps, done entirely through Classic, produce this screen every time:

      8. While writing this up, I decided to try different kinds of parameters. And they are all affected by this same issue: they default to whatever the user last did in Blue Ocean, as opposed to defaulting to the values listed in the Jenkinsfile. Example:

        1. image-2017-09-18-13-19-12-729.png
          467 kB
          Karl Shultz
        2. image-2017-09-18-13-21-01-611.png
          394 kB
          Karl Shultz
        3. image-2017-09-18-13-21-51-231.png
          296 kB
          Karl Shultz
        4. image-2017-09-18-13-24-32-315.png
          485 kB
          Karl Shultz
        5. image-2017-09-18-13-26-38-936.png
          480 kB
          Karl Shultz
        6. image-2017-09-18-13-29-44-375.png
          393 kB
          Karl Shultz

            vivek Vivek Pandey
            kshultz Karl Shultz
            5 Vote for this issue
            7 Start watching this issue