Viewing linked Jira issues in Bamboo
Asked by Artsiom_Tverdakhleb:

We are using a Bamboo script task to update linked Jira tickets.

We have tech users locally in both systems and use them to do REST calls.

Recently all automation fell down, as it was asking Bamboo tech user to log in to Jira, to be able to see linked issues.

Why that could have happened?

Is there a way to avoid this?

Is it possible to connect users using a code, not UI?


Answers:
author: Daniel Santos
body: Hello [@Artsiom_Tverdakhleb](/t5/user/viewprofilepage/user-id/2770693)

Let me add some comments on your messages to make sure we are aligned.
> We are using a Bamboo script task to update linked Jira tickets.
>
> We have tech users locally in both systems and use them to do REST calls.

I assume you are using username and password for that, right?
> Recently all automation fell down, as it was asking Bamboo tech user to log in to Jira, to be able to see linked issues.

What was the error you saw in Bamboo script?
> Why that could have happened?

If the requests were without password, it might be the case of a permission change in Jira side for the affected user.
> Is there a way to avoid this?

I'll need to make sure I understand the problem correctly first. I would start checking:

1. How is the REST API called
2. What is the error you see in Bamboo side
3. What are the permissions for the user in Jira side

> Is it possible to connect users using a code, not UI?

When you say connect, are you talking about login? I guess I will need the data shared above to understand better what is happening there.

comments: author: Artsiom_Tverdakhleb
body: Hello [@Daniel Santos](/t5/user/viewprofilepage/user-id/502125),

Thank you for your reply.

> I assume you are using username and password for that, right?

Yes, that's right.
> What was the error you saw in Bamboo script?

That was 401, but not actually from Bamboo. You see, the REST API we were calling is:
> [/result/{projectKey}-{buildKey}-{buildNumber : (\[0-9\]+)\|(latest)}?expand=jiraIssues](https://docs.atlassian.com/atlassian-bamboo/REST/6.8.1/#d2e4347)

So that request was actually returning 401 from Jira. As any other requests to Bamboo were returning the correct information. For example this call:
> [/deploy/projectVersioning/{deploymentProjectId}/variables](https://docs.atlassian.com/atlassian-bamboo/REST/6.8.1/#d2e3)

From the above, I decided to log in into Bamboo with tech user. In the UI on the linked issues page in the Build plan, I saw that it was asking to log in into Jira to see linked issues. So somehow Bamboo or Jira is connecting this both users.

Hope this information would answer your questions.

Regards, Artsiom


author: Daniel Santos
body: Now that I reproduced the issue I can tell you what possibly happened.  
One of the possible causes for this was the application links recreation.

I suppose that when you (or your team) created the application link the option "\[\] **servers have the same set of users and usernames"**was not checked. Considering the scenario where the base of users is possibly different, the Atlassian apps will use a token to identify which user is linked to which user. In other words, when I access with user A, Bamboo will use the user B (that was linked to A) to access Jira. In your case, these users have possibly the same name.

When the application links are created as described above we have to link at least one time the pair of users and this will happen when receiving a message requesting you to log in, then **Allow**the linking. Once that is done you don't need to redo it unless:

* The approval was removed in one of the apps
* Or, the application link was recreated. When this happens the users will need to be linked again.

Does that make sense to you?


author: Artsiom_Tverdakhleb
body: Hello [@Daniel Santos](https://community.atlassian.com/t5/user/viewprofilepage/user-id/502125),

Yes, thank you a lot.


Tags: bamboo-development

developer

jira

jira-server

rest-api