0

Is there any workaround that I can retrieve the Build Environment settings for every job in a groovy script ? For example I installed the 'Scriptler plugin' and the 'EnvInject plugin' and I want to find out for every job that I have if "manage exclusion" is ticked or not :

enter image description here

what I did is:

println String.format( "<b>List of JOBS :</b>" )`
println ''

for(item in jenkins.model.Jenkins.instance.getAllItems(hudson.model.Job.class)) 
{
  if(item instanceof hudson.model.ExternalJob)
    continue  

  println''

  for (env in item.builders)
    println env

}
Polyov
  • 2,281
  • 2
  • 26
  • 36

1 Answers1

0

I just found out how to do it...

println ''
println String.format( "<b> List all JOBS having exclusions defined :</b>" )
println ''

for(item in jenkins.model.Jenkins.instance.getAllItems(hudson.model.Job.class)) 
{
  if(item instanceof hudson.model.ExternalJob)
    continue   

  for(wrapper in item.getBuildWrappersList())
    if (wrapper instanceof org.jvnet.hudson.plugins.exclusion.IdAllocator)
      println item.name
}

To sum up......the changes that I did,I called the getBuildWrappersList to retrieve the Build Environment parameters.For my case,I was trying to find out which jobs were using the ArchiveArtifact plugin and display them for the user...

Build Environment capture

Cheers :)