【问题标题】:Jenkins and GitHub webhook: HTTP 403Jenkins 和 GitHub 网络钩子:HTTP 403
【发布时间】:2011-09-15 07:57:16
【问题描述】:

我有一个 GitHub 存储库,我想通过接收后挂钩通知 Jenkins 新提交。我已将 GitHub 插件安装到 Jenkins 中,并允许 Jenkins 管理它自己的挂钩 URL。该项目具有正确的 git 存储库 URL,并被指示“在将更改推送到 GitHub 时构建”。当我让 GitHub 发送一个测试有效负载时,我在前面的 Jenkins 的 nginx 网络服务器中找到了这个:

207.97.227.233 - - [15/Sep/2011:07:36:51 +0000] "POST /github-webhook/ HTTP/1.1" 403 561 "-" "-"

我正在运行 SSL,所以我禁用它没有效果。我是否需要在权限矩阵中为匿名用户提供特殊权限?

请原谅缺少配置文件:我很乐意分享那些可能存在但我不知道分享什么有用的东西。

【问题讨论】:

    标签: github hudson nginx jenkins git-post-receive


    【解决方案1】:

    由于我不允许匿名访问,因此我需要为 GitHub 推送创建一个特定用户并授予它整体读取、作业创建和作业读取权限。还需要将身份验证绑定到 webhook URL,如下所示:

    https://foo:password@jenkins.example.com/github-webhook/
    

    【讨论】:

    • 好一个。值得一提的是我的经验:我刚开始只是添加“作业阅读”。没用。然后我添加了“全面阅读”。那行得通。从来不用添加“工作创建”,所以我相信你可以不用它。
    【解决方案2】:

    来自Github's instructions(“配置全局身份验证”,第一节),

    1. Create a user in Jenkins which has, at a minimum, Job/Build permissions
    
    2. Log in as that user (this is required even if you are a Jenkins admin user), then click on the user's name in the top right corner of the page
    
    3. Click 'Configure,' then 'Show API Token...', and note/copy the User ID and API Token.
    
    4. In GitLab, when you create webhooks to trigger Jenkins jobs, use this format for the URL and do not enter anything for 'Secret Token': http://USERID:APITOKEN@JENKINS_URL/project/YOUR_JOB
    

    就我而言,我使用了http://USERID:APITOKEN@myIPaddress:808/ 而没有使用project/YOUR_JOB

    【讨论】:

      【解决方案3】:

      如前所述,Jenkins 不允许匿名访问(您不希望人们为您触发构建!)。明文添加用户名和密码并不是最好的解决方案。

      1) 如果您的 Jenkins 在 VPN 后面,您需要确保您的 Jenkins webhook URL 已公开

      2) 在 GitHub 插件配置中,在 Override Hook URL 中添加正确的可访问 Jenkins webhook URL(https://jenkins.example.com/github-webhook/)

      3) 在Shared secret 部分添加一个秘密(最好是一个长的随机字符串)。这将是从 Jenkins 发送到 GitHub 的令牌,反之亦然以进行身份​​验证。这应该与 GitHub 服务器凭据不同!

      4) 确保用户拥有将 webhook 添加到您的 GitHub 存储库的所有者权限

      5) 不要忘记在此之后重新注册 webhook

      【讨论】:

        【解决方案4】:

        https://username:password@jenkins.example.com/github-webhook/ 为我工作,但必须对密码进行编码才能使有效负载工作。由于 nginx 授权,我的 github 无法联系 jenkins,但传递用户名和编码密码有效!

        【讨论】:

          猜你喜欢
          • 2018-06-27
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2016-09-05
          • 2021-11-09
          • 2019-01-02
          • 2011-12-16
          • 1970-01-01
          相关资源
          最近更新 更多