2

我正在使用下面的 curl 命令将 test.xml 作业导入 rundeck,但它不起作用。

curl -v "X-Rundeck-Auth-Token:XXXXX" -F xmlBatch=@"/home/ec2-user/test.xml" --insecure https://hostaname:4443/api/14/project/DistributedArchitecture/jobs/import

我在 Linux 机器上收到以下错误:

Error:  HTTP/1.1 100 Continue
< HTTP/1.1 400 Bad Request
< Set-Cookie: JSESSIONID=co8wd4jqamut1i8ejwdqu6g7z;Path=/
< Expires: Thu, 01 Jan 1970 00:00:00 GMT
< Content-Type: text/xml;charset=UTF-8
< X-Rundeck-API-Version: 17
< Transfer-Encoding: chunked
< Server: Jetty(7.6.0.v20120127)
HTTP error before end of send, stop sending
<result error='true' apiversion='17'>
<error code='api.error.jobs.import.invalid'>
<message>Jobs Document was invalid for format xml: rundeck. controllers. JobXMLException: Document root tag was not 'joblist': 'Error'</message>
</error>
Closing connection 0
4

1 回答 1

2

我使用下面的命令来做同样的事情,这对我有帮助。

 curl -v -H x-rundeck-auth-token:<YOUR TOKEN> http://RUNDECK-SERVER:4440/api/16/project/<Job-Name>/jobs/import -F xmlBatch=@"job.xml" 

这就是我的 job.xml 的样子

<joblist>
<job>
<description>Job Description here!!</description>
<dispatch>
  <excludePrecedence>true</excludePrecedence>
  <keepgoing>false</keepgoing>
  <rankOrder>ascending</rankOrder>
  <successOnEmptyNodeFilter>false</successOnEmptyNodeFilter>
  <threadcount>1</threadcount>
</dispatch>
<executionEnabled>true</executionEnabled>
<loglevel>INFO</loglevel>
<name>MyJobName-xyz</name>
<nodeFilterEditable>false</nodeFilterEditable>
<nodefilters>
  <filter>localhost</filter>
</nodefilters>
<nodesSelectedByDefault>true</nodesSelectedByDefault>
<scheduleEnabled>true</scheduleEnabled>
<sequence keepgoing='false' strategy='node-first'>
  <command>
    <description>listing</description>
    <exec>ls --all</exec>
  </command>
</sequence>
</job>
</joblist>

这将在目标中执行简单的列表。
希望这可以帮助。

于 2018-03-14T12:35:19.967 回答