如何将标头(用于 jenkins crumb)添加到 github webhook?

Posted

技术标签:

【中文标题】如何将标头(用于 jenkins crumb)添加到 github webhook?【英文标题】:How to add header (for jenkins crumb) to github webook? 【发布时间】:2020-02-02 18:15:30 【问题描述】:

我们正在尝试设置一个 webhook,以便我们可以使用 https://github.com/blar/blar/settings/hooks 在我们可公开访问的 Jenkins 服务器上触发作业

表单为我们提供了“有效负载 URL”字段,但没有提供额外标题的字段。这意味着我们不能提供 Jenkins crumb 以便请求可以正确地进行身份验证。如果没有带有 crumb 的标头,我们会从 webhook 传递中获得以下响应:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 403 No valid crumb was included in the request</title>
</head>
<body><h2>HTTP ERROR 403</h2>
<p>Problem accessing /ghprbhook. Reason:
<pre>    No valid crumb was included in the request</pre></p><hr><a href="https://eclipse.org/jetty">Powered by Jetty:// 9.4.z-SNAPSHOT</a><hr/>

</body>
</html>

我们如何告诉 github 我们要使用的标头???

【问题讨论】:

【参考方案1】:

请参考-https://***.com/a/59861256/1726235

尝试使用 API 密钥而不是密码进行身份验证

【讨论】:

【参考方案2】:

所以 github 目前不支持标头,但事实证明,在我的情况下,这完全是一条红鲱鱼。我只是错过了我的网址上的斜线https://***.com/a/51545557/1586965

【讨论】:

以上是关于如何将标头(用于 jenkins crumb)添加到 github webhook?的主要内容,如果未能解决你的问题,请参考以下文章

解决访问本地jenkins报错:No valid crumb was included in request for /jenkins/createItem by admin. Returning 4

Jenkins RestAPI调用出现Error 403 No valid crumb was included in the request

jenkins===当postman出现错误403 No valid crumb was included in the request的解决办法

Jenkins CORS 过滤器插件未添加 Access-Control-Allow-Origins 标头

接口测试之参数关联

jenkins 通过使用crumbissuer停止job