Jenkins/vars/hook.groovy

15 lines
435 B
Groovy
Raw Normal View History

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