REST call to JIRA returns credential error when re-running build

I created a PreChainAction task that calls Jira to retrieve jira issue details.
When I initiate the build from a JIRA Version release, it works fine.
When I rerun the same build from the Bamboo screen (build results summary -> rerun build), it fails with credential errors saying ‘You do not have an authorized access token’

Details:
I call jira as follows:

jiraRestResponse = jiraRestService.doRestCallViaApplink(jiraAppLink, "rest/api/latest/search/?jql=" + jql, Request.MethodType.GET, null);

the jiraAppLink has info that looks good in the debugger (same as when triggered from Jira).

When I call it like this:

jiraRestResponse = jiraRestService.doRestCallViaApplink(applicationLink, "rest/api/latest/search/?jql=" + jql, Request.MethodType.GET, null, TwoLeggedOAuthAuthenticationProvider.class );

It returns a different error (not missing credentials, but an error from JIRA itself), saying “Field ‘fixVersion’ does not exist or this field cannot be viewed by anonymous users.”

It looks like somehow the user is not valid/ not in the context?

How can I make this jira call work when doing a manual re-run?

1 Like