Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to use addShutdownHook with ScriptRunner?

Max Berger October 29, 2019

I want to be able to execute a specific action at the end of a script, regardless of the way of termination. That means, even if a script throws an exception, I want to be able to e.g. log a message. In Java, there is addShutdownHook, which also exists in Groovy. This however doesn't work with ScriptRunner, I assume because it is registered with the Jira-process, which is Java too. Seeing how System.exit() terminates the whole Jira instance, I find this likely.

So my question is: How can I register a shutdownhook or achieve my goal in another way if necessary? Please note that wrapping the whole script in a try-catch is not acceptable.

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Alejandro Suárez - TecnoFor
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
November 9, 2019

Hi @Max Berger Unfortunatelly i dont think there is another possible way besides try catch.

TAGS
AUG Leaders

Atlassian Community Events