Jenkins pipeline: No such DSL method Jenkins pipeline: No such DSL method jenkins jenkins

Jenkins pipeline: No such DSL method


remove the extra brackets from around the sumfunc2 invocation:

node {   stage 'test'   def whatThe = someFunc('textToFunc')   def whatThe2 = someFunc2('textToFunc2')}def someFunc(String text){    echo text    text}def someFunc2(String text2){    echo text2    text2}

Update:

In Groovy if a method's last argument is of type Closure, then when calling the method the closure can be outside of the brackets like:

def foo(whatever, Closure c) {}// Can be invoked asfoo(whatever, {    // This is the second argument of foo of type Closure})// It is also the same as writingfoo(whatever) {    // This is the second argument of foo of type Closure}

The reason that the original throws is because the following code

def whatThe = someFunc('textToFunc'){def whatThe2 = someFunc2('textToFunc2')}

is the same code as

def whatThe = someFunc('textToFunc') {    def whatThe2 = someFunc2('textToFunc2')}

This means that what the interpreter will be looking for is

someFunc(String text, Closure c)

and there is no such method


Since this answer is the first one I found when I lookup the "No such DSL method" message, I would like to add that it might also be the interface that is not matching. In my case the first parameter was a list, but I tried to call the method with an array. So please check your interface matches what you expect, and your parameters are passed in correctly.


In my case what was happening is that I was referencing a variable using: ${} that was expanding to an empty string:

env.VAR1=${VAR2}

in my case, var2 didn't really exists, so what I had to do was actually:

env.VAR1=env.VAR2.

Silly mistake from my end.