No valid crumb was included in the request

jenkins curl 报错 No valid crumb was included in the request,

由于之前用curl来获取jenkins job的运行状态,如下

curl -k -q -X POST -H 'Content-type: application/json' JENKINS——URL/jenkins/queue/item/123//api/json?pretty=true'

但是自从升级jenkins版本之后就报如下错误


HTTP Status 403 – Forbidden

HTTP Status 403 – Forbidden


Type Status Report

Message No valid crumb was included in the request

Description The server understood the request but refuses to authorize it.


Apache Tomcat/8.5.75

通过查看Jenkins官方文档

Jenkins : Remote access API

No valid crumb was included in the request_第1张图片

 发现从2.9版本之后增加了CSRF保护策略,可以通过执行一些命令获取账号密码然后给加到之前的curl命令中,但是根据这个办法尝试半天没有效果,随决定关闭CSRF服务。

CSRF Protection 参考官网介绍可以通过下面方式关闭该服务。

在Jenkins Script Console中运行下面代码

dson.security.csrf.GlobalCrumbIssuerConfiguration.DISABLE_CSRF_PROTECTION=true

你可能感兴趣的:(jenkins,运维)