Pre send script in groovy for jenkins
===

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..

Thanks in Advance