0

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?

ssedano
  • 8,322
  • 9
  • 60
  • 98

1 Answers1

0

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.

slide
  • 792
  • 7
  • 9