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

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

问题描述

我想通过向Jenkins发送一个post curl请求来禁用Jenkins作业。

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

我试过这样做:


  1. curl -X POST http://< server>:8080 /< jobname> / disable li>
  2. curl -X POST http://< server>:8080 /< jobname> / disable?token =< token>

  3. curl -u< username>:< token> POST http://< server>:8080 /< jobname> / disable

  1. curl -X POST http://<server>:8080/<jobname>/disable
  2. curl -X POST http://<server>:8080/<jobname>/disable?token=<token>
  3. curl -u <username>:<token> POST http://<server>:8080/<jobname>/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保护。您需要在请求中包含适当的碎片头。如上面链接的Jenkins wiki页面所述,可以从Jenkins API获取碎屑。 answer使用curl和crumb触发参数化构建显示了在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天全站免登陆