Browse Source

Add hook utility basic implementation

audit
William Petit 5 months ago
parent
commit
97aa9b61dd
1 changed files with 15 additions and 0 deletions
  1. 15
    0
      vars/hook.groovy

+ 15
- 0
vars/hook.groovy View File

@@ -0,0 +1,15 @@
1
+def call(String name) {
2
+    def rootDir = pwd()
3
+    def filepath = "${rootDir}/.jenkins/${name}.groovy"
4
+    def exists = fileExists(filepath)
5
+    if (!exists) {
6
+        println("No hook '${filepath}' script. Skipping.")
7
+        return
8
+    }
9
+    def hook = load(filepath)
10
+    if(hook.metaClass.respondsTo(hook, 'exec')) {
11
+        hook.exec()
12
+    } else {
13
+        error("Hook script '${filepath}' exists but does not expose an exec() function.")
14
+    }
15
+}

Loading…
Cancel
Save