Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 您可以在公共回购上使用github添加webhook通知吗?_Ruby_Git_Github - Fatal编程技术网

Ruby 您可以在公共回购上使用github添加webhook通知吗?

Ruby 您可以在公共回购上使用github添加webhook通知吗?,ruby,git,github,Ruby,Git,Github,我正在使用octokit for ruby尝试为公共回购创建webhook通知。我无法从文件中判断这是否可行,以下是我参考的文件: 是否只允许为您所参与的项目创建Webhook?我希望通过编程方式收到github上某些公共回购的通知。 我尝试使用以下代码创建webhook并获得404: github_client = Octokit::Client.new(:access_token => github_access_key) github_client.create_hook( 'g

我正在使用octokit for ruby尝试为公共回购创建webhook通知。我无法从文件中判断这是否可行,以下是我参考的文件: 是否只允许为您所参与的项目创建Webhook?我希望通过编程方式收到github上某些公共回购的通知。 我尝试使用以下代码创建webhook并获得404:

github_client = Octokit::Client.new(:access_token => github_access_key)
github_client.create_hook(
  'github/ghfw-build-extra',
  'web',
  {
    :url => "http://testsite.com/github_webhook_event_handler",
    :content_type => 'json',
    :insecure_url => '1'
  },
  {
    :events => ['push'],
    :active => true
  }
)
我得到的错误是:

Octokit::NotFound:POST:404-未找到//请参阅:
从/Users/bboy/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/octokit-4.2.0/lib/octokit/response/raise\u error.rb:16:在“on\u complete”中,您应该能够在公共回购上创建一个钩子,但确实提到:

  # Create a hook
  #
  # Requires authenticated client.
因此,在调用该方法之前,请确保您已通过身份验证

此外,同样的代码还提到了一个配置示例

  #     {
  #       :url => 'http://something.com/webhook',
  #       :content_type => 'json'
  #     },

在您的情况下,可能
testsite.com/github\u webhook\u event\u handler
应该是
http://testsite.com/github_webhook_event_handler

至少使用github UI,如果您没有写/管理权限,就不能为公共项目添加Webhook。我假设使用API也会发生同样的情况

我使用的是经过身份验证的用户,我的url中有http://我刚刚更改了真实的url。我在进行身份验证时遇到的错误是回购协议不存在。我更新了我的示例,使其更加完善clear@jas你有没有尝试过其他公开回购?或者通过您创建的公共回购?