How to list all jobs having a Groovy post build script in Jenkins ?

793 views
Skip to first unread message

valn...@gmail.com

unread,
Feb 12, 2016, 4:54:54 AM2/12/16
to Jenkins Users
Hi,

I want to know if there is way I can list all Jenkins jobs that are having "Groovy post build script" plug-in enabled for them.

Please let know if there is any way I can do this.


Thanks,
valnci

Victor Martinez

unread,
Feb 12, 2016, 5:24:49 AM2/12/16
to Jenkins Users
Yep, see the below steps:

1) Go to your script console in jenkins: http://yourJenkinsUrl/script

2) List jobs
Jenkins.instance?.items.each { println it.name }

3) List jobs with post build actions
Jenkins.instance?.items.findAll { it.getPublishersList() != null && it.getPublishersList().size() > 0 }.each { println it.name }

4) Look for the Groovy Post Build actions class

5) List jobs with Groovy Post Build actions
Jenkins.instance?.items.findAll { it.getPublishersList() != null && it.getPublishersList().size() > 0 && it.getPublishersList()?.get(org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder.class) }.each { println it.name }

I hope it helps

Cheers

valn...@gmail.com

unread,
Feb 15, 2016, 1:53:23 AM2/15/16
to Jenkins Users
Thanks Victor for the quick reply.


- valnci 
Reply all
Reply to author
Forward
0 new messages