問題描述
Email‑ext Pre 腳本使用 (Email‑ext Pre script usage)
How can I write a prescript to check whether an email is going to be triggered because of an upstream project cause (commit‑job A).
If it does trigger, I want to cancel the email triggering in job B. I have seen one cancel variable. I want to know how can I use it for checking and cancelling?
‑‑‑‑‑
參考解法
方法 1:
What you need to do is get at the cause of the current build. The build is provided to the pre‑send script via the "build" variable.
build.causes.each() { cause ‑>
if(cause instanceof Cause.UpstreamCause) {
cancel = cause.upstreamProject == 'commit‑job A'
}
}
This should set the cancel variable to true if the upstream project is the one you are interested in. The cancel variable is retrieved by email‑ext and if it is true, the sending of the email is stopped.
(by user1551970、slide)