URL of Jira ticket is incorrect on Bitbucket Cloud
Platform Notice: Cloud - This article applies to Atlassian products on the cloud platform.
Summary
When Bitbucket Cloud is integrated with Jira (either Cloud or Data Center), it's possible to mention a Jira issue key from the linked Jira instance on the following types of content inside Bitbucket:
- Commit messages;
- Pull Request description;
- Pull Request comments;
- Branch name.
Bitbucket is expected to provide a link to the Jira issue when an issue key is detected. Sometimes, the actual result is that the link is to a broken link OR to an incorrect Jira instance.
Environment
Bitbucket Cloud, integrated with either Jira Cloud or Jira Data Center.
Diagnosis
When clicking on a Jira issue link in Bitbucket, the link is to an incorrect Jira instance. Causing a 404/403 error. Or users might also be redirected to a different Jira issue from what they were expecting.
Cause
The root cause for this problem is possibly two Jira instances linked to Bitbucket use the same Jira issue key.
If you do not have two or more Jira instances linked to your Bitbucket Cloud workspace, this issue does not apply to your scenario. In this case, please contact support.
If both Jira instances have issue keys like ABC-### and ABC-###. For example, let's say we have "exampleinstance1.atlassian.net" and "exampleinstance2.atlassian.net" linked to a Bitbucket Cloud workspace called "workspace1". See the diagram below to better understand the example scenario:
If both instances have a project that is using ABC-### as its key, and a Bitbucket Cloud pull request comment mentions an issue with the key ABC-1, then the Jira link will always redirect the user to the instance that was linked to Bitbucket Cloud first. So in the example scenario above, if "exampleinstance1.atlassian.net" was the first Jira instance that was linked to "worspace1", and if "exampleinstance2.atlassian.net" also has an issue key that matches the issue that was mentioned, then the user will always get redirected to "exampleinstance1.atlassian.net" to resolve the conflict. The user will also get redirected to "exampleinstance1.atlassian.net" even if this Jira instance no longer exists.
Jira Cloud - A Bitbucket Cloud admin can verify if multiple Jira Cloud instances are linked to Bitbucket by navigating to your workspace settings > Installed Apps (under "Apps and Features"). If you have multiple apps labeled "Jira", this means that you have multiple Jira Cloud instances linked to Bitbucket.
Jira Data Center - A Bitbucket Cloud admin can verify if multiple Jira Data Center instances are linked to Bitbucket by navigating to the workspace settings > OAuth consumers (Under Apps and Features). If you see more than one OAuth consumer, this might mean that you have more than one Jira Data Center instance linked. You will need to verify what the OAuth consumer in question is being used for individually.
Workarounds:
Remove the additional Jira integration(s):
For Jira Cloud integrations:
If the additional Jira Cloud instance integration is unwanted, you can follow the steps below to remove it:
- As an admin, navigate to your workspace settings;
- Select Installed apps (under "Apps and Features");
- You will see more than one "Jira" app integration. Expand all of the Jira dropdowns, until you see the URL of the unwanted Jira link.
- Click on the "Remove" button, then accept. The instance should be successfully removed.
Please note that after removing the Jira instance, it might take a few minutes to update the links, depending on the number of repositories on your workspace
For Jira Data Center integrations:
If the additional Jira Data Center instance integration is unwanted, you can follow the steps below to remove it:
- As a Jira Data Center admin, navigate to Jira Settings > Applications > DVCS accounts.
- You should see the connected Bitbucket Cloud workspace on the list of available workspaces. Click on "..." > "Delete" to remove the integration. The link between both products should be removed.
Please note that after removing the Jira instance, it might take a few minutes to update the links, depending on the number of repositories on your workspace
Move project(s) to a new key:
For Jira Cloud integrations:
Please read the relevant Jira Cloud documentation on changing a project's issue key before proceeding. There are multiple things do consider when making this change. You may consider contacting Jira Cloud support for more details.
If you want to keep both Jira Cloud instances integrated with the Bitbucket Cloud workspace in question, you can follow the steps below from our Jira Cloud documentation to move the project to a new key to resolve the conflict. Please make sure to pick a new key that does not match an existing key from the other Jira Cloud instance:
From your project's sidebar, select Project settings > Details.
In the Key field, enter your desired key. Your project's key must:
be at least two characters long
start with an uppercase letter
and, contain only uppercase letters or numbers
Select Save details. This will start a re-index of the project.
- After the re-index is complete, navigate to the DVCS accounts section of Jira Cloud, and unlink the existing Bitbucket Cloud integration. This needs to be done on the Jira instance that just had the issue key change made.
- Recreate the Jira Cloud integration link, using the steps from this documentation: https://support.atlassian.com/bitbucket-cloud/docs/connect-bitbucket-cloud-to-jira-software-cloud/
For Jira Data Center integrations:
Please read the relevant Jira Data Center documentation on changing a project's issue key before proceeding. There are multiple things do consider when making this change. You may consider contacting Jira Data Center support for more details.
If you want to keep both Jira Data Center instances integrated with the Bitbucket Cloud workspace in question, you can follow the steps below from our Jira Data Center documentation to move the project to a new key to resolve the conflict. Please make sure to pick a new key that does not match an existing key from the other Jira Data Center instance:
- In the upper-right corner of the screen, select Administration > Projects, and select the relevant project.
- Locate the project that you'd like to change.
- Select Edit in the Actions column of the project you want to change.
- Edit the project key, and click Save details. Only project types for applications you have installed will be available. This will start a re-index of the project.
- After the re-index is complete, navigate to the DVCS accounts section of Jira Data Center, and unlink the existing Bitbucket Cloud integration. This needs to be done on the Jira instance that just had the issue key change made.
- Recreate the Jira Cloud integration link, using the steps from this documentation: https://support.atlassian.com/bitbucket-cloud/docs/connect-bitbucket-cloud-to-jira-software-server/
If any of the conditions below apply, please contact Bitbucket support if you are on a paid plan, or reach out on the Atlassian community if you are on the Free plan.
- If you are being redirected to an incorrect page with only a single Jira instance being linked to your Bitbucket workspace;
- If you are unable to remove the additional Jira integration;
- If the solution above does not fix your issue.