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").
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?
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.