Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Jenkins pipeline vars/doSomething.groovy
#!/usr/bin/env groovy
// Specify default values but allow overriding.
//
// dosomething {
// arg1 = true
// arg2 = false
// arg3 = "https://www.hotbot.com"
// }
def call(body){
// Define config
def config = [:]
// Default values
config['arg1'] = false
config['arg2'] = true
config['arg3'] = 'https://google.com'
// Merge provided config with the above default values
body.resolveStrategy = Closure.DELEGATE_FIRST
body.delegate = config
body()
// Do whatever needs to be done...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.