jenkins - How does one cancel a system groovy script -


in jenkins have system groovy script build step. there way cancel long running script, or have code within system groovy script can tell whether build has been cancelled?

jenkins interrupt thread running script when cancel build.

so can either manually check thread's interrupt status , abort script @ points, e.g.

if (thread.currentthread().interrupted()) {   throw new interruptedexception() } 

or can let groovy including threadinterrupt annotation in script, e.g.

@groovy.transform.threadinterrupt 

also make sure none of catch blocks swallow interruptedexception.


Comments