Jenkins pipeline: No such DSL 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.


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 as
foo(whatever, {
    // This is the second argument of foo of type Closure
})

// It is also the same as writing
foo(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