2017-10-16 83 views
0

有一段時間我一直無法從我的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)。你還建議我檢查什麼?

回答

0

我無法回答什麼時候確切但問題消失 - 我假設無論GitLab還是Shippable更新都改變了一些東西,因爲掛鉤重新開始工作,而我沒有采取任何行動。