Best Practice for Calling External REST API from workflow Post Function (Java)

Hi all,

Within a Jira workflow we have a set of steps which an issue goes through during its lifecyle. Each step in the workflow is linked to a workflow status, which we want to sync back to our own API. To clarify a bit more, we have a client that wants to have the status of his Jira issues to be synced back to our system as well.

Because all our clients are very important to us, we decided to create a Jira plugin(add-on) with a custom post function (written in Java), which he can install and add to his workflow, so each time a jira issue is moved to a different step, the post function is triggered, and the status is synced to our system.

The way we are trying to achieve this:

In the execute method of the post function class which extends from the AbstractJiraFunctionProvider, we basically check whether the ticket which was moved was actually linked to something in our system (by checking a custom value). We then also check the user who made the change and push this together with the status of the changed Jira issue to our system by using a post endpoint (restful api). For this call to be made, I first had to import a simple http client (OkHttp3) by using maven.

Before we can use this endpoint, there has to be a call made to our own api to retrieve a token (authentication). I would love to get some feedback on this. Do I have to create a “Jira plugin user” in my own system and retrieve the token with the same (hardcoded) credentials. Or is there a way to ask the user who installed the plugin to login just once and make Jira store that token, and retrieve it in the post function so I just have to make one call to update the status in our system. This plugin should at the end be reusable by other clients as well. Only thing we want to achieve for now is syncing the status of a jira issue back to our own system.

Thank you in advance! Would love to get some feedback on this one.

2 Likes

@mouradahy were you able to find out a way to make Jira store the token?