Jira transition in a workflow

Hi, I have a small query.

I have a post function script in a workflow transition according to which if that script executes successfully and an output is gained then transition from A->B goes through successfully. If not, then it stays at A.

Is is possible?

1 answer

This widget could not be displayed.

Hello,

you might want to do it with a validator (or a condition), but not with a post-function smile

 

If it's a post-function, it's too late, the transition is almost complete

If it's a validator, then yes, you can return a pass or fail

You do NOT want a condition.  It will be run every time JIRA looks at the issue to see if a user can use it.

Hi NIc,

Thanks for the confirmation. How can I implement the same through a validator. I will try to explain the whole scenario:

I have a groovy script, which shoots a curl command to Service Now, and gives an output in my JIRA logs. Based on that output, i want to make sure that the transition goes from A->B or stays at A.

My approach:

I have a custom field which gets populated in my JIRA ticket screen with the result of the grovy script mentioned above. So my requirement is, if custom field gets populated with value X then A->B should take place, if not(e.g. value Y) then transition stays at A.

 

You will need to embed your script in a validator. 

Are you using the script runner add-on?  If not, then you're going to need to write a validator that can run your connection and interpret the result as a pass/fail.

Hi Nic, I am using this scriplet in my Validator, but still not working, can you pls suggest:

 

if(finalOutput.contains("[inserted]"))
{
log.debug("Inside incident block");
//def servicenowid = customFieldManager2.getCustomFieldObjectByName("ServiceNow ID");
//log.debug("Service id=$servicenowid")
log.debug("Inside incident block");
issue.setCustomFieldValue(servicenowidfield,finalIncident);
workflowTransitionUtil.setAction (1531);//Transition B
}
else
{
log.debug("Inside Else block");
issue.setCustomFieldValue(servicenowidfield,"Not Created in Service Now");
workflowTransitionUtil.setAction (4);//Transition A
}

 

How can I optimize this script to the above condition?

 

As of now, my script is anyways going to B irrespective of the fact that it catches the else block only.

 

No, hang on, that's not what we were discussing.

You do NOT try to change the target of a transition while it's running.  And there's absolutely no way you should be even thinking of changing an issue in a validator.

A validator should validate something, returning "true" if it's ok, and "false" (with an optional error message) if it fails validation.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Published 9 hours ago in Bitbucket

Branch Management with Bitbucket

As a project manager, I have discovered that different developers want to bring their previous branching method with them when they join the team. Some developers are used to performing individual wo...

38 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you