The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Workflow Transition condition based on Response from HTTP POST

Tamil
June 26, 2020

I have a scenario where during Workflow transition, I would make JIRA send a HTTP POST to different application which responds with JSON message. If the application returns Success message the workflow would move to next transition(e.g TODO--> IN PROGRESS). If the external application returns an error, the issue should stay in TODO state itself.

How do i make this happen?

 

By referring to below post,I have added groovy post-function, where script fetches issue field values and send to external application. The response received is stored in custom field('ERROR").

https://community.atlassian.com/t5/Jira-Questions/Send-a-HTTP-POST-as-a-post-function/qaq-p/312384#U1417806

 

Now how do i add condition/block transition that, if external application returns error message, how to stop the transition happening(e.g. the issue should stay in TODO state itself with error message from external application)?

 

Please let me know how to achieve this?

 

 

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Answer accepted
Zafer Cakmak
June 27, 2020

Hi @Tamil 

 

if you want to block transition then you need to use validators. Scriptrunner has tutorial for validators:

https://scriptrunner.adaptavist.com/latest/jira/tutorials/scripted-validators-tutorial.html

 

If you tested your groovy script on script console, you can add a custom script validation like that:

import com.opensymphony.workflow.InvalidInputException 

// get http post response

if (response == "ERROR") { //control your response
throw new InvalidInputException("You cannot transition this issue because web service returned an error")
}

 

I hope it helps