Pre send script in groovy for jenkins

不羁岁月 提交于 2019-12-12 06:26:09

问题


i have two dependent jobs. i need help for groovy script in jenkins, for writing pre send script for email-ext plugin.

i want to check whether buid reason is upstream cause, then set cancel variable=true

But i don't know how to write if condition in groovy for jenkins..For seperate jobs, will there be any seperate classes in jenkins(so i can create instance and call upstream cause)

is there any way to check build cause of downstream job is due to upstream..

Please help me on this code snippet..


回答1:


Use Build.getCauses() method. It will return a list of causes for the build. Loop over it and check if there is an object of hudson.model.Cause.UpstreamCause among them.

To get the build object, use the following code snippet:

def thr = Thread.currentThread()
def build = thr?.executable

FYI, here is a link to the complete Jenkins Module API.



来源:https://stackoverflow.com/questions/11662669/pre-send-script-in-groovy-for-jenkins

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!