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

Pipeline String parameter default value is ignored

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Fixed but Unreleased (View Workflow)
    • Priority: Blocker
    • Resolution: Not A Defect
    • Component/s: pipeline
    • Labels:
      None
    • Environment:
      Running on Docker
      Version: 2.235.3
    • Similar Issues:

      Description

      I have a multibranch pipeline project, where I want to use string parameters, that I don't always need.

      When the build is triggered by a push to git, I get an error with the following stacktrace:

       java.lang.IllegalArgumentException: Null value not allowed as an environment variable: ReleaseVersion
       at hudson.EnvVars.put(EnvVars.java:379)
       at hudson.model.StringParameterValue.buildEnvironment(StringParameterValue.java:59)
       at hudson.model.ParametersAction.buildEnvironment(ParametersAction.java:145)
       at hudson.model.Run.getEnvironment(Run.java:2419)
       at org.jenkinsci.plugins.workflow.job.WorkflowRun.getEnvironment(WorkflowRun.java:492)
       at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1285)
       at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:125)
       at org.jenkinsci.plugins.workflow.libs.SCMSourceRetriever.lambda$doRetrieve$1(SCMSourceRetriever.java:157)
       at org.jenkinsci.plugins.workflow.libs.SCMSourceRetriever.retrySCMOperation(SCMSourceRetriever.java:107)
       at org.jenkinsci.plugins.workflow.libs.SCMSourceRetriever.doRetrieve(SCMSourceRetriever.java:156)
       at org.jenkinsci.plugins.workflow.libs.SCMSourceRetriever.retrieve(SCMSourceRetriever.java:96)
       at org.jenkinsci.plugins.workflow.libs.LibraryAdder.retrieve(LibraryAdder.java:157)
       at org.jenkinsci.plugins.workflow.libs.LibraryStep$Execution.run(LibraryStep.java:205)
       at org.jenkinsci.plugins.workflow.libs.LibraryStep$Execution.run(LibraryStep.java:154)
       at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
       at hudson.security.ACL.impersonate(ACL.java:367)
       at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
       at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
       at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
       at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
       at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
       at java.base/java.lang.Thread.run(Thread.java:834)
      

      The pipeline declaration used:

      properties([
              parameters([
                      string(name: 'ReleaseVersion', defaultValue: '', required:false),
                      string(name: 'DevelopmentVersion', defaultValue: '', required:false)
              ])
      ])
      library 'tsc-pipelines@master'
      
      echo "|${params.ReleaseVersion}|${params.DevelopmentVersion}|"
      

      I obviously want to use methods from the "library" that I include, it's just a debug pipeline code. If I delete the library inclusion part, the code runs.

      The code below also produces a similar error:

      properties([
              parameters([
                      string(name: 'ReleaseVersion', defaultValue: '', required:false),
                      string(name: 'DevelopmentVersion', defaultValue: '', required:false)
              ])
      ])
      
      pipeline {
          agent any
          stages {
              stage('asd') {
                  steps{
                      sh "echo ${params.ReleaseVersion}"
                  }
              }
          }
      }
      

      -------------

      The following code also produces a similar error:

      pipeline {
          parameters {
              string(name: 'ReleaseVersion', defaultValue: 'asd')
              string(name: 'DevelopmentVersion', defaultValue: 'asd')
          }
          agent any
          stages {
              stage('asd') {
                  steps{
                      sh "echo ${params.ReleaseVersion}"
                  }
              }
          }
      }
      

      The error:

      java.lang.IllegalArgumentException: Null value not allowed as an environment variable: ReleaseVersion
      	at hudson.EnvVars.put(EnvVars.java:379)
      	at hudson.model.StringParameterValue.buildEnvironment(StringParameterValue.java:59)
      	at hudson.model.ParametersAction.buildEnvironment(ParametersAction.java:145)
      	at hudson.model.Run.getEnvironment(Run.java:2419)
      	at org.jenkinsci.plugins.workflow.job.WorkflowRun.getEnvironment(WorkflowRun.java:492)
      	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1285)
      	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:125)
      	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:93)
      	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:80)
      	at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
      	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
      	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
      	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
      	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
      	at java.base/java.lang.Thread.run(Thread.java:834)
      

        Attachments

          Activity

          Hide
          rolaca11 László Stahorszki added a comment -

          I made a mistake.

          When editing the Jenkinsfile, the parameters are not updated until the next build.

          After that build, I kept replaying that outdated build. If I started a newly triggered build, I'd see that the default values are resolved as intended

          Show
          rolaca11 László Stahorszki added a comment - I made a mistake. When editing the Jenkinsfile, the parameters are not updated until the next build. After that build, I kept replaying that outdated build. If I started a newly triggered build, I'd see that the default values are resolved as intended

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            rolaca11 László Stahorszki
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: