简体   繁体   English

使用Groovy脚本从Jenkins Scriptler检索构建环境信息

[英]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 ? 有什么解决方法可以使我在groovy脚本中检索每个作业的Build Environment设置? 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 : 例如,我安装了“ Scriptler插件”和“ EnvInject插件”,并且我想找出是否勾选了“管理排除”的每个工作:

在此处输入图片说明

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... 总结一下……所做的更改,我调用了getBuildWrappersList来检索“构建环境”参数。就我而言,我试图找出正在使用ArchiveArtifact插件的作业并将其显示给用户。 ..

Build Environment capture 构建环境捕获

Cheers :) 干杯:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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