How to ensure that the workflow transition stops when a groovy script fails in workflow postfunction

Shreyance Shaw March 7, 2019

We have a groovy script in the Transition post function. 

How do i make sure that the transition only goes through if the script executes successfully ?

As of now even if the script fails the transition goes through. 

 

 

1 answer

1 vote
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 8, 2019

You don't.

A post-function can not stop a transition (well, they can if they fail catastrophically, but that can easily leave your issue data messed up too)

You need to move the script to a validator, but ideally only one that checks that the script will run ok when it's done as a post-function (you should not update anything in a validator, only check things)

Shreyance Shaw March 10, 2019

Hi Nic,

Thank you for the response.

We are to create a Confluence page during a transition, we need to ensure that the transition is done only when the page is created and remote link is established.

Is there a way to check if a Confluence page creation groovy script will run okay ?

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 11, 2019

There is no way to do that in full, but what I would do is write a script that tries to read what the page will be in a validator - if it fails to open a connection to Confluence or finds the page (you can't create pages with the same name as an existing page, so this is a good check), then fail the validator.

If it passes, then try to create the page in the post-function, and capture the result.  If you do get a failure, write more data back into the issue to tell the user the page failed to create!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events