Skip to main content
Skip table of contents

How to add multiple Jira application links?

With Bitbucket it is possible to create multiple application links to Jira. This means that the add-on potentially has multiple Jira instances to search for and locate issues. Without further settings, the add-on can, of course, not know which issue key can be found in which Jira instance and must search in all Jira instances by default. And only if the issue key is not found in all Jira instances the push/merge action is rejected.

However, since not every Bitbucket user must also be a Jira user on all Jira instances, this default behavior can lead to problems, as the push is rejected due to a lack of authentication to a Jira instance. In this case, further configuration is required.

Before we look at the further configuration, we will first describe the default behavior and the priority of the search.

Search sequence: Project links → Primary application link → All other application links

If the add-on has found an issue key, it will first search for issues in the Jira projects for which a project link exists. If there is no project link or the issue was not found via this link, the issue is searched for via the primary application link. And if no issue was found for the issue key here either, an attempt is made to find the issue via all other application links.

If there is no correct issue for a key, the add-on can only ensure this by searching for the corresponding issue key via all application links. And this is exactly where the problem lies, because Jira instances can also be contacted for which no authentication is possible because the Bitbucket user is not a Jira user on this instance. The error message in this case may not be as expected, because the error message says that the user could not authenticate to a Jira instance to search for the issue, stating that an OAuth token should be created:

Symptom

“Could not authenticate. Visit https://<bitbucket>/plugins/servlet/applinks/oauth/login-dance/authorize?applicationlinkID=<GUID> to link your Bitbucket account to your Jira account.

However, since the Bitbucket user is not a Jira user on this Jira instance, the user cannot resolve this situation.

Solution

The Bitbucket project configuration and the add-on configuration must be adjusted. We have to tell the add-on that the corresponding issue can only be found in a smaller number of Jira instances and does not have to be searched for in all of them. To achieve this, we proceed as follows:

  • Bitbucket project settings: If there are no project links yet, suitable project links must be created from the Bitbucket project to the Jira project. Now the add-on will search in these projects first, but still via all other application links if the issue is not found. https://confluence.atlassian.com/bitbucketserver/configuring-project-links-across-applications-976171951.html

  • Add-on settings: So that the add-on does not search via all other application links, we can tell the add-on that issues are only to be searched for in the project links. So if the issue is not found via the project links, no further Jira instances are requested and a missing issue is reported directly as an error. You will find the corresponding configuration at the end of the push or hook configuration page:

    image-20240330-083004.png

Perfomance

Even if all Bitbucket users had a valid connection to all Jira instances, the scope of the search should still be restricted in order to improve performance. This is because it naturally has a very high impact on performance if not all Jira instances need to be contacted to validate an issue key.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.