Jenkins/vars/hook.groovy

15 lines
451 B
Groovy
Raw Permalink Normal View History

2019-03-19 16:07:47 +01:00
def call(String name) {
def rootDir = pwd()
def filepath = "${rootDir}/.jenkins/${name}.groovy"
def exists = fileExists(filepath)
if (!exists) {
println("No hook '${filepath}' script. Skipping.")
return
}
def hook = load(filepath)
if(hook.metaClass.respondsTo(hook, 'exec')) {
hook.exec()
} else {
error("Hook script '${filepath}' exists but does not expose an exec() function.")
}
}