Can you please help me to create new JOB in RunDeck using Rest API

293 views
Skip to first unread message

Rahul

unread,
Jul 31, 2018, 3:42:41 PM7/31/18
to rundeck-discuss
Hello There:

I need your help to create a new JOB in RunDeck using Rest API or Jenkins plug-in.

Thanks in advance!


Alex Honor

unread,
Jul 31, 2018, 3:51:02 PM7/31/18
to rundeck...@googlegroups.com
Hi Rahul,

Yes, you can use the REST API to import a job definition. You can also use the `rd jobs load` CLI to do the same.

Thanks

--
You received this message because you are subscribed to the Google Groups "rundeck-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rundeck-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to rundeck-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rundeck-discuss/f5931149-be14-44a5-8adc-f7dc935ceb5b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Alex Honor

[Rundeck | a...@rundeck.com ]

Rahul

unread,
Jul 31, 2018, 4:34:06 PM7/31/18
to rundeck-discuss
Thank you so much, Alex.

Just want to make sure if this is the correct way to execute an API in RunDeck

 curl -X POST -H x-rundeck-auth-token:$RD_TOKEN -H "Content-Type: application/yaml" --data @/tmp/job_config2.yaml  http://10.0.0.9:4440/api/1/project/Jenkins-ci/jobs/import

I'm running it like mentioned above but seeing the following

<result error='true' apiversion='24'>
  <error code='api.error.jobs.import.invalid'>
    <message>Jobs Document was invalid for format xml: mapping values are not allowed here
 in "&lt;reader&gt;", line 1, column 35:
    - defaultTab: summary  description: 'Test import'  executionEnable ...
                                      ^
</message>
  </error>


JOB YAML file

- defaultTab: summary
  description
: 'Test import'
  executionEnabled
: true
  id
: 66520fa3-a161-4b7e-9fae-709648e7b96f
  loglevel
: INFO
  name
: JIRA integration
  nodeFilterEditable
: false
  nodefilters
:
    dispatch
:
      excludePrecedence
: true
      keepgoing
: false
      rankOrder
: ascending
      successOnEmptyNodeFilter
: false
      threadcount
: '1'
    filter
: localhost
  nodesSelectedByDefault
: true
  notification
:
    onfailure
:
      plugin
:
        configuration
:
          issue key
: EVOPS-1
        type
: JIRA
    onstart
:
      plugin
:
        configuration
:
          issue key
: EVOPS-1
        type
: JIRA
    onsuccess
:
      plugin
:
        configuration
:
          issue key
: EVOPS-1
        type
: JIRA
  notifyAvgDurationThreshold
: null
  scheduleEnabled
: true
  sequence
:
    commands
:
   
- description: hello
     
exec: echo "Hello World
    keepgoing: false
    strategy: node-first
  uuid: 66520fa3-a161-4b7e-9fae-709648e7b96f



Thanks,
Rahul

On Tuesday, July 31, 2018 at 2:51:02 PM UTC-5, Alex Honor wrote:
Hi Rahul,

Yes, you can use the REST API to import a job definition. You can also use the `rd jobs load` CLI to do the same.

Thanks
On Tue, Jul 31, 2018 at 12:42 PM, Rahul <rahulkuma...@motorolasolutions.com> wrote:
Hello There:

I need your help to create a new JOB in RunDeck using Rest API or Jenkins plug-in.

Thanks in advance!


--
You received this message because you are subscribed to the Google Groups "rundeck-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rundeck-discu...@googlegroups.com.
To post to this group, send email to rundeck...@googlegroups.com.



--

Alex Honor

[Rundeck | a....@rundeck.com ]

Alex Honor

unread,
Jul 31, 2018, 4:38:11 PM7/31/18
to rundeck...@googlegroups.com
Hi Rahul,
Add this query param to the URL:
fileformat=yaml

To unsubscribe from this group and stop receiving emails from it, send an email to rundeck-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to rundeck-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rundeck-discuss/2c09e970-3e6f-4e71-9d40-a7b48e76b91a%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Alex Honor

[Rundeck | a...@rundeck.com ]

Rahul

unread,
Jul 31, 2018, 4:49:25 PM7/31/18
to rundeck-discuss
Thanks Alex!
I got this created with XML type but still not with YAML

curl -X POST -H x-rundeck-auth-token:$RD_TOKEN -H "Content-Type: application/yaml" --data @/tmp/job_config2.yaml http://10.0.0.0:4440/api/14/project/Jenkins-ci/jobs/import fileformat=yaml

here is the error again

<result error='true' apiversion='24'>
 
<error code='api.error.jobs.import.invalid'>
   
<message>Jobs Document was invalid for format xml: mapping values are not allowed here
 in "&lt;reader&gt;", line 1, column 35:
    - defaultTab: summary  description: 'Test import'  executionEnable ...
                                      ^
</message>
 
</error>


am I adding this at right place?




--

Alex Honor

[Rundeck | a....@rundeck.com ]

Alex Honor

unread,
Jul 31, 2018, 4:58:54 PM7/31/18
to rundeck...@googlegroups.com
No need for a space between the url and the query param. EG http://10.0.0.0:4440/api/14/project/Jenkins-ci/jobs/import?fileformat=yaml

To unsubscribe from this group and stop receiving emails from it, send an email to rundeck-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to rundeck-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rundeck-discuss/b5eefd07-37a8-4cc4-b205-0ef154597941%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Alex Honor

[Rundeck | a...@rundeck.com ]

Rahul

unread,
Jul 31, 2018, 5:03:58 PM7/31/18
to rundeck-discuss
Sorry Alex!

Still same, Do i need to add anything to my config file

curl -X POST -H x-rundeck-auth-token:$RD_TOKEN -H "Content-Type: application/yaml" --data @/tmp/mynew.yaml http://10.0.0.0/4440/api/14/project/Jenkins-ci/jobs/import?fileformat=yaml

<result error='true' apiversion='24'>
 
<error code='api.error.jobs.import.invalid'>

   
<message>Jobs Document was invalid for format yaml: mapping values are not allowed here
 
in "&lt;reader&gt;", line 1, column 35:
   
- defaultTab: summary  description: ''  executionEnabled: true  id ...
                                     
^
</message>
  </
error>



--

Alex Honor

[Rundeck | a....@rundeck.com ]

Alex Honor

unread,
Jul 31, 2018, 5:09:38 PM7/31/18
to rundeck...@googlegroups.com
Hi Rahul,

One other change... use --data-binary rather than --data. 
EG curl -X POST -H x-rundeck-auth-token:$RD_TOKEN -H "Content-Type: application/yaml" --data-binary @/tmp/mynew.yaml http://10.0.0.0/4440/api/14/project/Jenkins-ci/jobs/import?fileformat=yaml

To unsubscribe from this group and stop receiving emails from it, send an email to rundeck-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to rundeck-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rundeck-discuss/6af73ca9-9a5c-4f08-ad84-072d6749d750%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Alex Honor

[Rundeck | a...@rundeck.com ]

Rahul

unread,
Jul 31, 2018, 5:12:11 PM7/31/18
to rundeck-discuss
Many Thanks, Alex it worked!

You are superb!



--

Alex Honor

[Rundeck | a....@rundeck.com ]

Reply all
Reply to author
Forward
0 new messages