Jenkins will interrupt the thread that runs the script when you cancel the assembly.
This way you can manually check the thread interrupt status and interrupt your script at specific points, for example.
if (Thread.currentThread().interrupted()) { throw new InterruptedException() }
Or you can let Groovy do this for you by including a ThreadInterrupt annotation in the script, for example
@groovy.transform.ThreadInterrupt
Also, make sure that none of your catch blocks will catch an InterruptedException.
source share