summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2017-06-03 23:48:56 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2017-06-03 23:48:56 +0100
commitc13a24c9a06333b110ed37ada6e0fb757f62a779 (patch)
treeedea5fb9a0d37f3c2b61fe576b1d4581a240d368
parentf0c2b82b5cc7e0d0b0674d16a18d7510000c2484 (diff)
downloadgp-packaging-tools-c13a24c9a06333b110ed37ada6e0fb757f62a779.tar.bz2
Stim converter tweaks
-rwxr-xr-xgp-stimulus-converter24
-rw-r--r--gp-stimulus-converter.conf1
2 files changed, 15 insertions, 10 deletions
diff --git a/gp-stimulus-converter b/gp-stimulus-converter
index a922763..f56fae1 100755
--- a/gp-stimulus-converter
+++ b/gp-stimulus-converter
@@ -84,17 +84,21 @@ local function handle_stanza(req, stanza)
-- Deal with the fact that Jenkins is so awful, it needs 'Basic'
-- and is case sensitive
myreq.headers:upsert("authorization", "Basic " .. myreq.headers:get("authorization"):sub(7), true)
- local headers, rstream = myreq:go()
- local status = headers:get(":status")
- local body = rstream:get_body_as_string(5)
- -- If Jenkins is behaving normally, status will be 201
- -- if the auth is bad, we get 403
- if status == "201" then
- results[#results+1] = ref .. " -> Triggered"
- elseif status == "403" then
- results[#results+1] = ref .. " !> Bad authentication data"
+ if pcre.match(ref, stanza.permitted_refs) then
+ local headers, rstream = myreq:go()
+ local status = headers:get(":status")
+ local body = rstream:get_body_as_string(5)
+ -- If Jenkins is behaving normally, status will be 201
+ -- if the auth is bad, we get 403
+ if status == "201" then
+ results[#results+1] = ref .. " -> Triggered"
+ elseif status == "403" then
+ results[#results+1] = ref .. " !> Bad authentication data"
+ else
+ results[#results+1] = ref .. " ?> Unknown status " .. status
+ end
else
- results[#results+1] = ref .. " ?> Unknown status " .. status
+ results[#results+1] = ref .. " ~> Ignored"
end
end
assert(#results > 0, "No changes found?")
diff --git a/gp-stimulus-converter.conf b/gp-stimulus-converter.conf
index 01ca91b..3666959 100644
--- a/gp-stimulus-converter.conf
+++ b/gp-stimulus-converter.conf
@@ -13,6 +13,7 @@ CONF = {
kind = "gp-debian",
path_prefix =
"^/(lua%-scrypt|luxio|clod|lace|gall|supple|tongue|gitano)",
+ permitted_refs = "^refs/(tags/.*|heads/master)$",
jenkins_trigger_pattern = "gp-source-prepare-%s",
jenkins_trigger_token = JENKINS_TRIGGER_TOKEN_GITANO,
jenkins_trigger_auth = JENKINS_TRIGGER_AUTH,