Started by upstream project "allocate" build number 31originally caused by: Started by upstream project "start" build number 12originally caused by:
我尝试了groovy postbuild与以下内容:
def build = Thread.currentThread().executabledef causes= manager.build.getCauses()for (cause in causes){manager.Listener.logger.println "upstream build: " + cause.getShortDescription()}
但后来我只得到“分配”,而不是“开始”工作.
我也试过了
def build = Thread.currentThread().executabledef test = build.getUpstreamBuilds()for (up in test){manager.Listener.logger.println "test build project: " + up}
但这是空的……
有任何想法吗?
解决方法 您接近第一个解决方案.实际上,你需要做的是根据它的类型迭代这个原因的祖先.
以下是可以帮助您入门的示例代码段:
def printCausesRecursively(cause) { if (cause.class.toString().contains("UpstreamCause")) { println "This job was caused by " + cause.toString() for (upCause in cause.upstreamCauses) { printCausesRecursively(upCause) } } else { println "Root cause : " + cause.toString() }}for (cause in manager.build.causes){ printCausesRecursively(cause)}
您可能需要参考文档来处理所有原因类型:http://javadoc.jenkins-ci.org/hudson/model/Cause.html
希望能帮助到你,
最好
总结以上是内存溢出为你收集整理的groovy – 让Jenkins上游工作全部内容,希望文章能够帮你解决groovy – 让Jenkins上游工作所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)