REST api to trigger a job in the build pipeline

257 views
Skip to first unread message

Ramnath Ananth

unread,
Jan 29, 2016, 1:36:43 PM1/29/16
to Jenkins Users
Hello,

I am trying to trigger a deploy job remotely using REST api and so far I couldn't find any api which would know if the job is linked to the pipeline or not.

I want to trigger a build job A. After successful completion of job A , I want to trigger deploy job B. But there is no api to link the two jobs although I can directly trigger job B successfully.

Please can anyone help me on this.

Thanks
Ramnath

Discussion link from dev group : https://groups.google.com/d/topic/jenkinsci-dev/ucokqMfMQnA/discussion


Jason Tran

unread,
Jan 29, 2016, 4:35:47 PM1/29/16
to Jenkins Users

Ramnath Ananth

unread,
Jan 29, 2016, 5:27:53 PM1/29/16
to Jenkins Users
Hi Jason.

I have used the mentioned build with parameters option and it works through REST api. But the build result is not getting reflected in the Build pipeline view. It is still in its original pipeline color and the builds are not getting promoted further.

Thanks
Ramnath

Ramnath Ananth

unread,
Jan 29, 2016, 6:50:06 PM1/29/16
to Jenkins Users
My question is the same as this discussion

Michael Neale

unread,
Jan 31, 2016, 10:09:39 PM1/31/16
to Jenkins Users
Ramnath, some questions: 

1) what type of job - freestyle, workflow/pipeline or something else? 
2) when you say "trigger a deploy job remotely" - do you mean create the job? or just trigger it to run ? 

Normally what people do is check "Build after other projects are built" on JobB config (in the "Build Triggers" section) - and put JobA in there. Then, any time JobA completes, JobB will run. 

Alternatively, in JobA you could put a post build action to trigger JobB. 

Then, from an api, you only ever need to trigger JobA and JobB will follow. 

Otherwise, I don't know what you mean by "linked to the pipeline or not". 

Ramnath Ananth

unread,
Jan 31, 2016, 10:23:49 PM1/31/16
to jenkins...@googlegroups.com

Hi Michael

This is a freestyle job and yes, I am triggering the job to run.

I tried your solution to add post build action to trigger job B after job A is triggered through the api and it works.

But my use case is to trigger job B not immediately but at any given time.

So as of now whenever I trigger job B using /job/JobB/build api job B successfully runs , but I can't see it on the UI pipeline view of jenkins , the way you see it in the pipeline view when you trigger from the UI

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/vRD9NG03dYE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/24045c04-9b9c-4c2d-b084-b9d7bde66925%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael Neale

unread,
Feb 1, 2016, 1:21:07 AM2/1/16
to Jenkins Users
OK I think I understand. So you can trigger jobA (and things work as expected) but sometimes you want to trigger jobB without jobA, but you still want it to show up in the pipeline view you have? 

I don't think there is a way to do that at the moment, as the pipeline viewer plugins only look at the starting job I believe (starting at B would almost look like a different pipeline). 

I wonder if one way is to trigger jobA, but with an optional parameter that makes its steps a no-op, so it just flows on to jobB (that is the best I can think of). 

Ramnath Ananth

unread,
Feb 1, 2016, 1:31:26 AM2/1/16
to Jenkins Users
Yes, for example imagine job A to be build job for a project and job B is a job to deploy the artifacts archived from job A to a DEV or a UAT environment.

Basically I want to deploy artifacts to an environment using job B through the REST api, in which I am not successful so far. Maybe this is not possible currently through REST.

Will have to explore more.

Michael Neale

unread,
Feb 1, 2016, 2:26:46 AM2/1/16
to Jenkins Users
Well you certainly can call jobB, but I think you want it to show up in the plugin visualisation. 


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

-- 
Regards, 

Michael Neale
(twitter: @michaelneale, skype: michael_d_neale)
Cofounder & Engineer @ large in CTO office. 

Ramnath Ananth

unread,
Feb 1, 2016, 9:04:18 AM2/1/16
to jenkins...@googlegroups.com

Ramnath Ananth

unread,
Feb 2, 2016, 7:27:52 PM2/2/16
to Jenkins Users
Is there a way to tweak the build api source code so that it can sync with the UI pipeline and show its results ?

Any help in this will be great .

Thanks
Ramnath

Yes , thats correct.

To unsubscribe from this group and all its topics, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
--

-- 
Regards, 

Michael Neale
(twitter: @michaelneale, skype: michael_d_neale)
Cofounder & Engineer @ large in CTO office. 

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/vRD9NG03dYE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-users+unsubscribe@googlegroups.com.

Michael Neale

unread,
Feb 2, 2016, 7:59:08 PM2/2/16
to Jenkins Users
Are you using this plugin? https://wiki.jenkins-ci.org/display/JENKINS/Build+Pipeline+Plugin

There are a few that do that type of thing, not sure how involved that type of change would be.

Yes , thats correct.

--

-- 
Regards, 

Michael Neale
(twitter: @michaelneale, skype: michael_d_neale)
Cofounder & Engineer @ large in CTO office. 

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/vRD9NG03dYE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-use...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/vRD9NG03dYE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-use...@googlegroups.com.

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

Ramnath Ananth

unread,
Feb 2, 2016, 8:12:32 PM2/2/16
to jenkins...@googlegroups.com
Yes, I am using the build pipeline plugin and am going through the source code to see if I can change it to accommodate my requirement.

Sony Koithara

unread,
Mar 28, 2017, 3:05:02 PM3/28/17
to Jenkins Users
Very much curious to know about this..

Was anybdy able to figure out how we can do this ?

-Sony Koithara
Reply all
Reply to author
Forward
0 new messages