简体   繁体   中英

Retrieve Build Environment info from Jenkins Scriptler with Groovy script

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 :

在此处输入图片说明

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

}

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 :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM