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

Label accepts 2 groovy variables when using && but not || operator

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • workflow-cps-plugin
    • None

      When running a pipeline, the label expects a string with the option of an operator. Apparently the && operator with 2 groovy variables will evaluate correctly but not a || operator.

      So this pipeline runs correctly:

       

      def groovyLabel1 = 'master'
      def groovyLabel2 = 'TestAgent'
      node(groovyLabel1 && groovyLabel2){
      echo "hello"
      }
      

      But this code does not run correctly:

       

      def groovyLabel1 = 'master'
      def groovyLabel2 = 'TestAgent'
      node(groovyLabel1 || groovyLabel2){
      echo "hello"
      }

      because it fails with this error:

       

      java.lang.ClassCastException: org.jenkinsci.plugins.workflow.support.steps.ExecutorStep.label expects class java.lang.String but received class java.lang.Boolean
      

       

      I think that groovy is doing some funky parsing here and causing the error because what should be the only thing allowed would be something like this:

      node('master || TestAgent'){
      echo "hello"
      }
      

       

            Unassigned Unassigned
            ataylor Alex Taylor
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: