feeding parameters to the jenkins shared library

When you get an error “no such DSL method…” it often just means that the types of parameters and actually passed arguments are incompatible, which is the case here.

The function examFun() expects an array, but you are actually passing an ArrayList. As explained in this answer, low level arrays are not really idiomatic in Groovy.

Try this instead:

def examFun(List<String> val){
  return [
     new randClass(name: val[0], place: 'London')
     new randClass(name: val[1], place: 'Berlin')
  ]
}

List is the more general interface, which ArrayList implements.

Now, your first jenkinsfile example should work:

jenkinsPipeline.examFun(['Name 1','Name 2'])

You actually can have additional named methods, even when you already have a call method. I’m using this all the time.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top