如何通过 curl 禁用 Jenkins 作业? [英] How to disable a Jenkins job via curl?

查看:25
本文介绍了如何通过 curl 禁用 Jenkins 作业?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过向 Jenkins 发送卷后请求来禁用 Jenkins 作业.

I want to disable a Jenkins job by sending a post curl request to Jenkins.

我试过这样做:

  1. curl -X POST http://:8080//disable
  2. curl -X POST http://:8080//disable?token=
  3. curl -u <用户名>:<令牌>POST http://:8080//disable

但每次都失败.我得到的错误是:

but failed every time. The error i am getting is:

403 请求中没有包含有效的面包屑

403 no valid crumb was included in the request

有没有好的基于 curl 的解决方案来解决这个问题?

Is there a good curl based solution to this problem?

推荐答案

碎屑错误表明您正在使用 CSRF 保护.您需要在请求中包含正确的 crumb 标头.可以从上面链接的 Jenkins wiki 页面中描述的 Jenkins API 获取面包屑.使用 curl 和 crumb 触发参数化构建"的 answer 显示了在 curl 请求中添加 crumb 标头的语法.

The crumb error indicates you are using CSRF Protection. You need to include a proper crumb header in your request. The crumb can be obtained from the Jenkins API as described on the Jenkins wiki page linked above. The answer for "Trigger parameterized build with curl and crumb" shows the syntax to adding the crumb header in the curl request.

这篇关于如何通过 curl 禁用 Jenkins 作业?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆