diff --git a/vars/hook.groovy b/vars/hook.groovy new file mode 100644 index 0000000..1f8cd71 --- /dev/null +++ b/vars/hook.groovy @@ -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.") + } +} \ No newline at end of file