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

Jenkinsfile parameter default values not evaluted on first-run when read from scm

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • pipeline
    • None

      As of... Jenkins 2.235.4

      To reproduce

      1. Create a jenkinsfile on SCM
      2. Give it a parameter of any type (for example, a string named "greeting")
      3. Give it some default value of "Hello World"
      4. Add a step to echo the value of "greeting"
      5. Add a new jenkins job: type=pipeline
      6. Choose "pipeline script from scm"
      7. Point to the Jenkinsfile you added in step 1
      8. Click "build" button
        • Of note, "Build with parameters isn't an option because Jenkins doesn't know that the job has a parameter when it's added this way". I believe this is the root of the issue.

      So, the first run of the job should print "null" rather than "Hello World" because using the "build" button seems to set all the parameters to "null" instead of using their default values. 

      After the first run, the job will have a "Build with parameters" button, so the issue will never occur again.

      I'm not sure what a sensible approach is to resolving this issue, but i brought it up in IRC and several people said they had been dealing with the same bug historically and just accepted it.  

            Unassigned Unassigned
            solvingj jerry wiltse
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: