summaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2012-08-17 22:18:48 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2012-08-17 22:18:48 +0100
commit53e805632ef0b8d659d6702f0066e83e99042aea (patch)
tree56cc3575195df81cdf8e038d15af5741734529fb /example
parentfe6e18bb39062972d31097362bdeeaa9cdaac417 (diff)
downloadgitano-53e805632ef0b8d659d6702f0066e83e99042aea.tar.gz
EXAMPLE: Jenkins-notify global post-receive hook example
Diffstat (limited to 'example')
-rw-r--r--example/global-hooks/jenkins-notify.post-receive.lua40
1 files changed, 40 insertions, 0 deletions
diff --git a/example/global-hooks/jenkins-notify.post-receive.lua b/example/global-hooks/jenkins-notify.post-receive.lua
new file mode 100644
index 0000000..e2f2d31
--- /dev/null
+++ b/example/global-hooks/jenkins-notify.post-receive.lua
@@ -0,0 +1,40 @@
+-- jenkins-notify.post-receive.lua
+--
+-- Example post-receive global hook which notifies a Jenkins instance on
+-- any and all refs updates (except refs/gitano/*) which happen.
+--
+-- It notifies Jenkins *before* passing the updates on to the project hook.
+--
+-- Copyright 2012 Daniel Silverstone <dsilvers@digital-scurf.org>
+--
+-- This is an example which is part of Gitano.
+--
+
+local project_hook, repo, updates = ...
+
+local jenkinshost = "ci.gitano.org.uk"
+local basepath = "/jenkins/git/notifyCommit?url="
+local urlbase = "git://git.gitano.org.uk/"
+
+local notify_jenkins = false
+
+for ref in pairs(updates) do
+ if not ref:match("^refs/gitano/") then
+ notify_jenkins = true
+ end
+end
+
+if notify_jenkins then
+ log.state("Notifying Jenkins...")
+ local code, msg, headers, content =
+ http_get(jenkinshost, basepath .. urlbase .. repo.name .. ".git")
+ if code ~= "200" then
+ log.state("Notification failed somehow")
+ end
+ for line in content:gmatch("([^\r\n]*)\r?\n") do
+ log.state("jenkins: " .. line)
+ end
+end
+
+-- Finally, chain to the project hook
+return project_hook(repo, updates)