-
Bug
-
Resolution: Unresolved
-
Minor
-
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" }
Well, more accurately, the && case doesn't actually run properly, it just doesn't error out due to being a boolean. It's still bad code - the expected behavior there would be that groovyLabel1 && groovyLabel2 evaluates to a boolean, not to a string, and so shouldn't be valid for node. I remember looking into this a bit before I went on a business trip last week and now I can't remember what I figured out. Grr. I'm pretty sure it was coercion magic doing strange things, but not sure.