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

NodeLabel parameters are null objects in pipeline script params

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Accessing the parameter with param will give you a null object, but accessing it through env and global will give you the string of one node.

      Example:

      properties ([
          parameters([
              [
                   $class: 'BooleanParameterDefinition',
                   defaultValue: false,
                   description: 'This will do a clean and build of the project.',
                   name: 'Rebuild'
              ],
              [
                   $class: 'NodeParameterDefinition',
                   allowedSlaves: ['ALL (no restriction)'],
                   defaultSlaves: ['master'],
                   description: 'What nodes to run the build on.',
                   name: 'NODE_PARAM',
                   nodeEligibility: [$class: 'AllNodeEligibility'],
                   triggerIfResult: 'allowMultiSelectionForConcurrentBuilds'
              ]
          ])
      ])
      
      echo "NODE_PARAM: " + NODE_PARAM.getClass().toString()
      echo "env.NODE_PARAM: " + env.NODE_PARAM.getClass().toString()
      echo "params.NODE_PARAM: " + params.NODE_PARAM.getClass().toString()
      
      

      Will give you this output:

      [Pipeline] echo
      NODE_PARAM: class java.lang.String
      [Pipeline] echo
      env.NODE_PARAM: class java.lang.String
      [Pipeline] echo
      params.NODE_PARAM: class org.codehaus.groovy.runtime.NullObject
      

      As you can see, only params.NODE_PARAM is null. 

      The problem is that I can not use env.NODE_PARAM or NODE_PARAM to get multiple selection of nodes, as those are only a string representation of a single node.

       

        Attachments

          Activity

          Hide
          macdrega Joerg Schwaerzler added a comment - - edited

          Can confirm. Another issue would be that only the params. version would return the default value for the label or node paramter when called for the first time.

          Show
          macdrega Joerg Schwaerzler added a comment - - edited Can confirm. Another issue would be that only the params. version would return the default value for the label or node paramter when called for the first time.

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            snellingen Matias Snellingen
            Votes:
            9 Vote for this issue
            Watchers:
            12 Start watching this issue

              Dates

              Created:
              Updated: