def call(String name) { def filepath = "${env.WORKSPACE}/.jenkins/${name}.groovy" def exists = fileExists(filepath) if (!exists) { println("No hook '${filepath}' script. Skipping.") return } def hook = load(filepath) if (hook == null) { error("Hook '${filepath}' seems to be null. Did you forget to add 'return this' at the end of the script ?") } if (hook.metaClass.respondsTo(hook, 'exec')) { hook.exec() } else { error("Hook script '${filepath}' exists but does not expose an exec() function.") } }