Snippets

Adaptavist Bitbucket Post Hook Jenkins trigger

Created by Mark McCormack

File bb-post-hook-jenkins-trigger.groovy Added

  • Ignore whitespace
  • Hide word diff
+import com.atlassian.stash.hook.HookResponse
+import com.atlassian.stash.repository.RefChange
+import com.atlassian.stash.repository.Repository
+import groovyx.net.http.HTTPBuilder
+
+def hookResponse = hookResponse as HookResponse
+def refChanges = refChanges as Collection<RefChange>
+def repository = repository as Repository
+
+refChanges.each { refChange ->
+    if (refChange.ref.displayId in ["sample"]) {
+        def httpBuilder = new HTTPBuilder("http://jenkins:8080")
+        httpBuilder.get(
+            path: "/git/notifyCommit",
+            query: [url: "ssh://git@somewhere.com:7999",
+                    branches: refChange.ref.displayId
+            ]
+        )
+    }
+}
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.