简体   繁体   English

Jenkins curl命令返回XML而不是调用job

[英]Jenkins curl command returns XML instead of calling job

I'm calling a Jenkins job remotely using a curl command, like this: 我正在使用curl命令远程调用Jenkins作业,如下所示:

C:\Windows\system32>"C:\Program Files (x86)\Git\usr\bin\curl.exe" -X POST -u [user]/[password] http://[server]:8080/job/[job]/buildWithParameters?NODE=[node]

The Jenkins job is never run. Jenkins的工作永远不会执行。 Instead on the command line, the command returns a big chunk of XML (I cut out most of the middle section, but it's mostly references to js and css files): 相反,在命令行上,该命令返回了一大段XML(我在中间部分中剪了大部分,但是大部分是对js和css文件的引用):

  <!DOCTYPE html><html><head data-rooturl="" resURL="/static/a7b46c37" data-resu
rl="/static/a7b46c37">
    <title>Jenkins</title><link rel="stylesheet" type="text/css" href="/static/a
7b46c37/css/layout-common.css" /><link rel="stylesheet" type="text/css" href="/s

...

    function showTranslationDialog() {
      if(!translation.launchDialog)
        loadScript("/static/a7b46c37/plugin/translation/dialog.js");
      else
        translation.launchDialog();
      return false;
    }</script></div></div></div></footer></body></html>

The user didn't have Build permission on the job. 用户没有该作业的“构建”权限。 Once I gave it Build permission, the command didn't return any XML, and the Jenkins job ran fine. 一旦我授予了Build许可,该命令就不会返回任何XML,并且Jenkins作业运行良好。

To authenticate with basic auth, you should use: 要使用基本身份验证进行身份验证,您应该使用:

-u [user]:[password]

instead of: 代替:

-u [user]/[password]
  • if the job you're trying to run has it's own token, add the query param to the end of the url: 如果您要运行的作业具有其自己的令牌,则将查询参数添加到url的末尾:

    &token=[token] &token = [令牌]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM