Skip to content
This repository was archived by the owner on Jan 31, 2019. It is now read-only.

Commit 753f02d

Browse files
committed
Response Status function
1 parent 802c5c6 commit 753f02d

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

docs/github_payload

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
"api_version" => "2.0.alpha1",
66
"username" => "jamie.winsor",
77
"password" => "passw0rd",
8-
"server_url" => "http://jira"
8+
"server_url" => "http://jira",
9+
"ontime_url" => "http://mahsamwin7/OT11/",
10+
"api_key" => "anything"
911
},
1012

1113
"payload" => {

services/ontime.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,18 @@ def receive_push
1414

1515
#Hash the data
1616
sha256 = Digest::SHA2.new(256)
17-
hash = sha256.digest(payload.to_json + api_key)
17+
hash = sha256.digest(payload.to_json + data['api_key'])
1818

1919
result = http_post "api/scm_files", :payload => payload.to_json, :hash => hash, :source => :github
2020

21-
if(result.status != 200)
22-
raise_config_error "Post status returned: " + result.status
21+
verify_response(result)
22+
end
23+
def verify_response(res)
24+
case res.status
25+
when 200..299
26+
when 403, 401, 422 then raise_config_error("Invalid Credentials")
27+
when 404, 301, 302 then raise_config_error("Invalid YouTrack URL")
28+
else raise_config_error("HTTP: #{res.status}")
2329
end
2430
end
25-
end
31+
end

0 commit comments

Comments
 (0)