2

I am using curl command below to import a test.xml job to rundeck but it is not working.

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

I am getting the following error on Linux box:

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
Charlie Fish
  • 18,491
  • 19
  • 86
  • 179
Arpit Garg
  • 31
  • 1
  • 1
  • 5

1 Answers1

2

I used below command to do the same which helped me.

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

And this is how my job.xml looks like

<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>

This will do simple list all in a target.
Hope this helps.

Faysal Ahmed
  • 7,501
  • 5
  • 28
  • 50
Unmil
  • 21
  • 3