本文介绍了詹金斯·格罗维(Jenkins Groovy):触发工作的原因的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Jenkins.instance.getAllItems(AbstractProject.class).each {it ->
println it.fullName
println it.getLastBuild().getTime()
}

我想获取自动触发的作业列表.现在我有了所有工作的清单.

I want to get list of jobs triggered automatically. Now i have list of all jobs.

推荐答案

您可以获取原因触发了构建.

You can get the Cause which triggered the build.

Jenkins.instance.getAllItems(AbstractProject.class).each {
  hudson.model.Cause cause = it.getLastBuild().getCause(hudson.model.Cause.class)
  println "Is triggered by user: " + (cause.class == hudson.model.Cause.UserIdCause.class)
}

此类具有许多子类,您可以确定哪些子类触发了构建:

This class has many subclasses, which you can you to determine what triggered the build:

这篇关于詹金斯·格罗维(Jenkins Groovy):触发工作的原因的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 07:15