新增时向grimoirelab推送事件,异常处理
This commit is contained in:
parent
48fe09345e
commit
e907cae4dc
|
@ -9,7 +9,7 @@ class IssueWebhookJob < ApplicationJob
|
||||||
user = issue.user
|
user = issue.user
|
||||||
domain = "#{Rails.application.config_for(:configuration)['platform_url']}"
|
domain = "#{Rails.application.config_for(:configuration)['platform_url']}"
|
||||||
gitea_domain = GiteaService.gitea_config[:domain]
|
gitea_domain = GiteaService.gitea_config[:domain]
|
||||||
ssh_url = "git@#{gitea_domain.gsub("https://","")}:#{project.owner.login}/#{project.identifier}.git"
|
ssh_url = "git@#{gitea_domain.gsub("https://", "")}:#{project.owner.login}/#{project.identifier}.git"
|
||||||
event_json = {
|
event_json = {
|
||||||
"action": "opened",
|
"action": "opened",
|
||||||
"number": 1,
|
"number": 1,
|
||||||
|
@ -161,21 +161,26 @@ class IssueWebhookJob < ApplicationJob
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
url = URI("http://117.50.185.50:80")
|
begin
|
||||||
http = Net::HTTP.new(url.host, url.port)
|
url = URI("http://117.50.185.50:80")
|
||||||
request = Net::HTTP::Post.new(url)
|
http = Net::HTTP.new(url.host, url.port)
|
||||||
request["Content-Type"] = "application/json"
|
request = Net::HTTP::Post.new(url)
|
||||||
uuid = SecureRandom.uuid
|
request["Content-Type"] = "application/json"
|
||||||
request['X-GitHub-Delivery'] = uuid
|
uuid = SecureRandom.uuid
|
||||||
request['X-Gitea-Delivery'] = uuid
|
request['X-GitHub-Delivery'] = uuid
|
||||||
request['X-Gogs-Delivery'] = uuid
|
request['X-Gitea-Delivery'] = uuid
|
||||||
request['X-GitHub-Event'] = 'issues'
|
request['X-Gogs-Delivery'] = uuid
|
||||||
request['X-Gitea-Event'] = 'issues'
|
request['X-GitHub-Event'] = 'issues'
|
||||||
request['X-Gogs-Event'] = 'issues'
|
request['X-Gitea-Event'] = 'issues'
|
||||||
request.body = JSON.dump(event_json)
|
request['X-Gogs-Event'] = 'issues'
|
||||||
|
request.body = JSON.dump(event_json)
|
||||||
|
|
||||||
response = http.request(request)
|
response = http.request(request)
|
||||||
Rails.logger.info "issue webhook event======#{response.read_body}"
|
Rails.logger.info "issue webhook event======#{response.read_body}"
|
||||||
|
rescue Exception => e
|
||||||
|
Rails.logger.info "issue webhook event error======#{e.message}"
|
||||||
|
puts "issue webhook event error======#{e.message}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
Loading…
Reference in New Issue