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

Pipeline automatically convert mistyped parameters

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      The type of the parameters pased to a pipeline with the build step are not checked on any of the two sides, this can cause that your received a type that does not match with the type expected. The following two pipelines demonstrate a case where you send a Boolean and you expect a String, then you can a String.trim() method and fails because the parameter is boolean that does not honor the definition.

      pipeline {
          agent any
          stages {
              stage('Hello') {
                  steps {
                       build(job: "job02",
                          parameters: [booleanParam(name: 'TEST', value: true)],
                          propagate: false,
                          wait: false
                        )
                  }
              }
          }
      }
      
      pipeline {
          agent any
          parameters {
              string(name: 'TEST')
          }
          stages {
              stage('Hello') {
                  steps {
                      echo "${params.TEST.trim()}"
                  }
              }
          }
      }
      

      The resulted exception

      Started by upstream project "job01" build number 3
      originally caused by:
       Started by user unknown or anonymous
      Running in Durability level: MAX_SURVIVABILITY
      Loading library apm@current
      FSSCM.checkout /var/pipeline-library to /var/jenkins_home/workspace/job02@libs/apm
      FSSCM.check completed in 190 milliseconds
      [Pipeline] Start of Pipeline
      [Pipeline] node
      Running on local in /tmp/workspace/job02
      [Pipeline] {
      [Pipeline] stage
      [Pipeline] { (Hello)
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: java.lang.Boolean.trim() is applicable for argument types: () values: []
      Possible solutions: wait(), grep(), wait(long), grep(java.lang.Object), or(java.lang.Boolean), is(java.lang.Object)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:153)
      	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:161)
      	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:165)
      	at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)
      	at WorkflowScript.run(WorkflowScript:9)
      

        Attachments

          Activity

          ifernandezcalvo Ivan Fernandez Calvo created issue -
          ifernandezcalvo Ivan Fernandez Calvo made changes -
          Field Original Value New Value
          Environment Jenkins Core 2.289.1
          Pipeline: Declarative 1.85
          Jenkins Core 2.289.1
          Pipeline: Declarative 1.85
          Pipeline: Build Step 2.13
           

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            ifernandezcalvo Ivan Fernandez Calvo
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: