11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/add_webhooks.rb', line 11
def post(organization,student,reponame,user,pass,url)
payload ='{
"name": "web",
"active": true,
"events": ["push"],
"config": {
"url": "' + url + '",
"content_type": "json"
}
}'
post_url = @@host + "/repos/" + organization + "/" + student + "-" + reponame + "/hooks"
uri = URI(post_url)
Net::HTTP.start(uri.host,uri.port,
:use_ssl => uri.scheme = 'https') do |http|
request = Net::HTTP::Post.new(uri, = {'Content-Type' =>'application/json'})
request.basic_auth user, pass
request.body = payload
http.request request do |response|
response.read_body do |chunk|
puts chunk
end
end
end
end
|