Ruby无法调用可发布webhook端点
问题描述:
有一段时间我一直无法从我的GitLab实例运行webhooks。起初我以为这是与GitLab upgrade〜10.0发布或某些iptables相关的东西,但现在我认为它可能是更多的Ruby事情以及如何调用可发布的终结点(在Ruby中?)。Ruby无法调用可发布webhook端点
在失败的请求的网站,我可以看到以下信息:
- ,失败的原因是
execution expired
- 网址是
https://[username:password]@api.shippable.com/projects/[project id]/newBuild
- 它是由可发送自动生成扶持项目 - X-Gitlab,事件类型是
Push Hook
- 还有JSON与请求主体
首先,我测试枯萎其实我可以用可发送从服务器
curl --verbose -X POST -H "Content-Type: application/json" -H "X-Gitlab-Event: $event" --data "$json" $url
请求成功,这让我觉得它不是iptables的事项连接(但是我检查,没有,没有iptables规则进行设置) 。
然后我试图重新里面/opt/gitlab/embedded/bin/irb
该请求:
require 'net/http'
require 'net/https'
uri = URI.parse(url)
username = uri.userinfo.split(':')[0]
password = uri.userinfo.split(':')[1]
req = Net::HTTP::Post.new(uri.path, {'Content-Type' =>'application/json', 'X-Gitlab-Event' => event})
req.basic_auth username, password
req.body = json
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
response = http.start { |http| http.request(req) }
然后失败就像在GitLab有:
Net::OpenTimeout: execution expired
from /opt/gitlab/embedded/lib/ruby/2.3.0/net/http.rb:880:in `initialize'
from /opt/gitlab/embedded/lib/ruby/2.3.0/net/http.rb:880:in `open'
from /opt/gitlab/embedded/lib/ruby/2.3.0/net/http.rb:880:in `block in connect'
from /opt/gitlab/embedded/lib/ruby/2.3.0/timeout.rb:101:in `timeout'
from /opt/gitlab/embedded/lib/ruby/2.3.0/net/http.rb:878:in `connect'
from /opt/gitlab/embedded/lib/ruby/2.3.0/net/http.rb:863:in `do_start'
from /opt/gitlab/embedded/lib/ruby/2.3.0/net/http.rb:852:in `start'
from (irb):142
from embedded/bin/irb:11:in `<main>'
有趣的是类似的事情发生在我的本地机器上:卷曲而红宝石成功抛出。
此外,我检查了它不应该是一个基本的身份验证,SSL或POST的问题 - 我成功地从我的服务器的irb上发布了Bitbucket上的片段,就像我测试可发布webhook端点一样。我甚至用几乎相同的请求格式在我的模拟服务器上发布了可执行请求。
在这一点上,我很好奇这种行为的原因以及如何进一步调试。我发现在所有失败案例中唯一的两个因素是目标(可发布的URI)和客户端(Ruby的Net :: HTTP)。你还建议我检查什么?
答
我无法回答什么时候确切但问题消失 - 我假设无论GitLab还是Shippable更新都改变了一些东西,因为挂钩重新开始工作,而我没有采取任何行动。