Bitbucket Server does not link commit to JIRA after setting custom JIRA issue key regex

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

Symptoms

Bitbucket Server integration with JIRA does not work because JIRA project key has number for example, TST3

After setting custom JIRA issue key regex in Bitbucket Server ([A-Z][A-Z0-9]+), the following appears in the atlassian-bitbucket.log:

1 2 3 4 5 6 7 8 9 10 11 2012-11-08 23:34:38,037 DEBUG [http-7990-4] kahloun.foong 1414x24x1 o068uh 0:0:0:0:0:0:0:1%0 "GET /projects/TST/repos/bitbucket/commits HTTP/1.1" com.atlassian.bitbucket.scm.BaseCommand Executed /opt/local/bin/git for-each-ref --sort=-objecttype --format=%(objecttype)|%(refname)|%(refname:short)|%(objectname)|%(*objectname) refs/heads/ refs/tags/ 2012-11-08 23:34:38,538 DEBUG [http-7990-4] kahloun.foong 1414x24x1 o068uh 0:0:0:0:0:0:0:1%0 "GET /projects/TST/repos/bitbucket/commits HTTP/1.1" com.atlassian.bitbucket.scm.BaseCommand Executed /opt/local/bin/git rev-list --format=%H|%h|%P|%p|%an|%ae|%at%n%B%n@@object_end@@ --stdin -- 2012-11-08 23:34:40,373 WARN [http-7990-4] kahloun.foong 1414x24x1 o068uh 0:0:0:0:0:0:0:1%0 "GET /projects/TST/repos/bitbucket/commits HTTP/1.1" c.a.s.i.w.s.f.WebPanelFunction An error occurred rendering com.atlassian.bitbucket.bitbucket-jira-integration:jira-issues-commit-list-panel. Ignoring java.lang.ArrayIndexOutOfBoundsException: 1 at com.atlassian.bitbucket.integration.jira.web.JiraKeyContextProvider$JiraKey.fromString(JiraKeyContextProvider.java:117) ~[na:na] at com.atlassian.bitbucket.integration.jira.web.JiraKeyContextProvider$1.apply(JiraKeyContextProvider.java:64) ~[na:na] at com.atlassian.bitbucket.integration.jira.web.JiraKeyContextProvider$1.apply(JiraKeyContextProvider.java:61) ~[na:na] at com.google.common.collect.Iterators$8.next(Iterators.java:782) ~[guava-10.0.1.jar:na] at java.util.AbstractCollection.toArray(AbstractCollection.java:124) ~[na:1.6.0_37] at java.util.ArrayList.<init>(ArrayList.java:131) ~[na:1.6.0_37] at com.google.common.collect.Lists.newArrayList(Lists.java:119) ~[guava-10.0.1.jar:na]

Diagnosis

Run the following SQL query to search for incorrect issue key:

1 SELECT * FROM cs_attribute WHERE att_value NOT LIKE '%-%';

The column att_value from the result is not a Issue Key but a Project key

Cause

The regex added is incorrect so project key is added into the database instead of issue key.

Solution

Resolution

  1. Backup Bitbucket Server for rollback purposes

  2. Stop Bitbucket Server

  3. Modify the custom JIRA issue key regex in Bitbucket Server to have the correct format: BSERV-2784 - Document specifying a custom JIRA issue key regex

  4. Delete the incorrect value in the database:

    1  DELETE FROM cs_attribute WHERE att_value NOT LIKE '%-%';
  5. Start Bitbucket Server

  6. Perform a new commit into Bitbucket Server (The new commit will have link to JIRA)

Updated on April 15, 2025

Still need help?

The Atlassian Community is here for you.