Remote Access API - REST API in Jenkins

754 views
Skip to first unread message

Pradeep Patra

unread,
Jul 28, 2017, 2:03:27 AM7/28/17
to Jenkins Users
Hi all,

I am using Jenkins 2.71 trying to use Remote Access API plugin for creating jobs outside the Jenkins. I was referring to the  below plugin.

When I search in Manage Plugins I could not find any plugin with this name? I have got Remote Terminal access plugin. How can I install this plugin. Does it have separate hpi?
I was trying to find a suitable example for creating job based on xml/JSON for creating jobs based on a specific build?

Regards
Pradeep

Michael Pailloncy

unread,
Jul 28, 2017, 4:54:13 AM7/28/17
to jenkins...@googlegroups.com
Remote Access API is available directly, without need to install any plugin.
By accessing http://${YOUR_JENKINS}/api url, you should be able to see a page listing different ways to interact with it (see "Create Job").

You have also a full example here using curl to create a new job based on XML with or without folder.

However, what do you mean by "for creating jobs based on a specific build" ?

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/02ea4100-29b8-4d08-88ea-1b920e84eff5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Pradeep Patra

unread,
Jul 28, 2017, 5:46:32 AM7/28/17
to Jenkins Users


On Friday, July 28, 2017 at 4:54:13 PM UTC+8, mpapo - Michael Pailloncy wrote:
Remote Access API is available directly, without need to install any plugin.
By accessing http://${YOUR_JENKINS}/api url, you should be able to see a page listing different ways to interact with it (see "Create Job").

You have also a full example here using curl to create a new job based on XML with or without folder.

I tried it and it is asking for mode? I am not sure what is the mode I should provide for creating new job. I tried passing  mode=create and it did not work.

However, what do you mean by "for creating jobs based on a specific build" ?

I mean the new job should "execute shell" to package local packages. I guess that I can achieve with the buildWithParameters and by passing the command. If  you have any example could you please let me know.

2017-07-28 8:03 GMT+02:00 Pradeep Patra <smileso...@gmail.com>:
Hi all,

I am using Jenkins 2.71 trying to use Remote Access API plugin for creating jobs outside the Jenkins. I was referring to the  below plugin.

When I search in Manage Plugins I could not find any plugin with this name? I have got Remote Terminal access plugin. How can I install this plugin. Does it have separate hpi?
I was trying to find a suitable example for creating job based on xml/JSON for creating jobs based on a specific build?

Regards
Pradeep

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.

Michael Pailloncy

unread,
Jul 30, 2017, 7:21:08 PM7/30/17
to jenkins...@googlegroups.com

I tried it and it is asking for mode? I am not sure what is the mode I should provide for creating new job. I tried passing  mode=create and it did not work.

Can you share the command line which you've tried please ?
 

However, what do you mean by "for creating jobs based on a specific build" ?

I mean the new job should "execute shell" to package local packages. I guess that I can achieve with the buildWithParameters and by passing the command. If  you have any example could you please let me know.

You can find an example of a build trigger with parameters from command line here.

Pradeep Patra

unread,
Jul 30, 2017, 9:44:19 PM7/30/17
to Jenkins Users


On Monday, July 31, 2017 at 7:21:08 AM UTC+8, mpapo - Michael Pailloncy wrote:

I tried it and it is asking for mode? I am not sure what is the mode I should provide for creating new job. I tried passing  mode=create and it did not work.

Can you share the command line which you've tried please ?

I planned to first try in GUI: http://<Jenkins-URL>:8080/createItem?name=testjob it gave me error that please specify a valid mode. Then I changed it to name=testjob & mode=create but it still did not work.

curl -v -X POST http://<username>:<jenkins-pass>@<Machine-IP>:8080/createItem?name=newjob  –user <username>:<API-Token> --data-urlencode json='{"parameter": [{"name":"id", "value":"123"}, {"name":"verbosity", "value":"high"}]}'

Can you please help here in this regard? 

Michael Pailloncy

unread,
Jul 31, 2017, 8:16:18 AM7/31/17
to jenkins...@googlegroups.com
The "mode" parameter is expected here since you are triggering a job copy instead of a job creation (it's the same API endpoint, it differs only with the number/kind of parameters).

To trigger a job creation, you need something like : 

curl -v -XPOST 'http://<JENKINS_IP>:<JENKINS_PORT>/createItem?name=bimbilimbimbim' --data-binary @config.xml -H "Content-Type:text/xml" --user <username>:<API-Token>

With config.xml is a local file containing your new job configuration.

You can go to http://${JENKINS_IP}:${JENKINS_PORT}/api  with your browser to have documentation about that (Create Job and Copy Job).

Hopefully it helps.


--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/c8f8ba34-8af7-4a5a-8de6-b98f88b821c1%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages