如何在Jenkins中禁用CSRF保护?

rseugnpd  于 12个月前  发布在  Jenkins
关注(0)|答案(1)|浏览(242)

我正在尝试设置一个Jenkins管道,每当我的bitbucket存储库中有新的代码推送时,它就会触发。我尝试创建一个bitbucket webhook URL http://<jenkins_URL>/job/<pipeline_name>/build?token=<token_name>,并在repo中有推送时运行它。然而,每当回购中有推送时。流水线不是自动触发的。在检查时,我发现webhook正在接收来自jenkins的403错误代码,

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 403 No valid crumb was included in the request</title>
</head>
<body><h2>HTTP ERROR 403 No valid crumb was included in the request</h2>
<table>
<tr><th>URI:</th><td>/job/<pipeline-name>/build</td></tr>
<tr><th>STATUS:</th><td>403</td></tr>
<tr><th>MESSAGE:</th><td>No valid crumb was included in the request</td></tr>
<tr><th>SERVLET:</th><td>Stapler</td></tr>
</table>
<hr/><a href="https://eclipse.org/jetty">Powered by Jetty:// 10.0.13</a><hr/>

</body>
</html>

我尝试用hudson.security.csrf.GlobalCrumbIssuerConfiguration.DISABLE_CSRF_PROTECTION=true属性重新启动Jenkins,但没有成功。有没有什么方法可以禁用CSRF,或者更好的方法来自动化我的管道,这样我就不必禁用CSRF了?

7cwmlq89

7cwmlq891#

我有同样的问题,你必须禁用CSRF以下。
导航“管理Jenkins”->“脚本控制台”。
然后,执行下面的操作。

import jenkins.model.Jenkins

def instance = Jenkins.instance
instance.setCrumbIssuer(null)

相关问题