Created
October 29, 2018 14:54
-
-
Save tvon/024456da7e9932023855152488a53017 to your computer and use it in GitHub Desktop.
Jenkins pipeline vars/doSomething.groovy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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