Add hook utility basic implementation

Este commit está contenido en:
wpetit 2019-03-19 16:07:47 +01:00
padre ec523ddfb4
commit 97aa9b61dd
Se han modificado 1 ficheros con 15 adiciones y 0 borrados

15
vars/hook.groovy Archivo normal
Ver fichero

@ -0,0 +1,15 @@
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.")
}
}