Reputation: 133
As per Job DSL plugin API documentation for Git, there are two forms to use it:
What is the difference between these two approaches ?
One is a method call and the other one is calling a closure ?
As per this article, I guess both forms are calling a Groovy closure + some Groovy syntactic sugar.
Upvotes: 0
Views: 210
Reputation: 936
One is a method call and the other one is calling a closure ?
Both are method calls - but the first takes a string on git
- while the latter takes a closure as argument.
As per the api-doc api you shared above, it looks like the first one - git {}
- provides maximum options to setup the SCM context - that includes an option to manipulate directly the generated XML through configure
closure. All the others seem to be the variants of this option with the last argument as the configure
closure.
If the last parameter of a method call is a closure, it can be passed outside the parentheses
Yes, you are right. And, if the closure is the only method argument, then method can be called with just that and without any parentheses. That's exactly what the first call is about git {}
Upvotes: 0