jenkins java api

20 views
Skip to first unread message

Danny Wong

unread,
Jan 25, 2017, 1:16:28 PM1/25/17
to jenkins...@googlegroups.com

Hi guys,

            I would like to retrieve all the jobs (and their name) in a specific Jenkins pipeline. I’m looking at Jenkins api using groovy examples, but I have not found the option.

 

I found this example:

// Get the list of all jobs and print them

//activeJobs = hudson.model.Hudson.instance.items.findAll{job -> job.isBuildable()}

 

//activeJobs.each{run -> println(run.name)}

//println  ('total number of jobs :'+ activeJobs.size())

 

 

Which gives me ALL builds and their names… I only want the builds from a specific pipeline view. Any suggestions? Thanks!

 




______________________________________________________________________

The contents of this electronic message, including any attachments, are intended only for the use of the individual or entity to which they are addressed and may contain confidential information. If you are not the intended recipient, you are hereby notified that any use, dissemination, distribution, or copying of this message or any attachment is strictly prohibited. If you have received this transmission in error, please send an e-mail to postm...@whitehatsec.com and delete this message, along with any attachments, from your computer.

khmarbaise

unread,
Jan 25, 2017, 1:37:03 PM1/25/17
to Jenkins Users, danny...@whitehatsec.com
Hi,

you should get only the appropriate job by selecting via name and then you can get information about a part of the job like a pipeline part...may be via the REST API ? I never tried to use this within a pipeline itself...

Kind regards
Karl Heinz Marbaise

Danny Wong

unread,
Jan 25, 2017, 1:39:54 PM1/25/17
to khmarbaise, Jenkins Users

Hi,

I can get all the build names via REST api fine when I make an external call to a python script. I wanted to try implementing within Jenkins groovy scripting.

Danny Wong

unread,
Jan 25, 2017, 1:48:11 PM1/25/17
to khmarbaise, Jenkins Users

Ok. It looks like I found the Jenkins java api class to give me what I want.

Reply all
Reply to author
Forward
0 new messages