Skip to content

Instantly share code, notes, and snippets.

@pokle
Last active April 25, 2017 17:43
Show Gist options
  • Save pokle/8394174 to your computer and use it in GitHub Desktop.
Save pokle/8394174 to your computer and use it in GitHub Desktop.
How to run an external script from source control in the Jenkins Build Flow plugin DSL
//
// Copy this into your Jenkins Build Flow plugin DSL, and call run_workspace_script() with the name of your checked in script
//
// Based on code at http://jorgemanrubia.net/2009/10/10/evaluating-code-dynamically-in-groovy
//
def run_workspace_script(filename) {
def code = new File(build.workspace.child(filename).toString()).text
def code_as_closure = "{->${code}}"
def closure = evaluate(code_as_closure)
closure.delegate=this
closure()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment