Skip to content

Instantly share code, notes, and snippets.

@tvon
Created October 29, 2018 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tvon/024456da7e9932023855152488a53017 to your computer and use it in GitHub Desktop.
Save tvon/024456da7e9932023855152488a53017 to your computer and use it in GitHub Desktop.
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