Add hook utility basic implementation
This commit is contained in:
parent
ec523ddfb4
commit
97aa9b61dd
15
vars/hook.groovy
Normal file
15
vars/hook.groovy
Normal file
@ -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.")
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user