Unable to Connect to a Private Repository using the DVCS Plugin

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

Symptoms

Attempting to connect to a repository fails with the error "Unable to link selected repository. Do you have administrator permissions on the {GitHub|BitBucket} repository you are attempting to sync?", as below:

(Auto-migrated image: description temporarily unavailable)

The following appears in the atlassian-jira.log:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2013-04-17 23:07:00,806 http-bio-65210-exec-15 ERROR admin 1386x7942x1 10omna6 172.22.236.74 /rest/bitbucket/1.0/repo/8/autolink [common.error.jersey.ThrowableExceptionMapper] Uncaught exception thrown by REST service com.atlassian.jira.plugins.dvcs.exception.SourceControlException: Could not add postcommit hook. Not Found (404) at com.atlassian.jira.plugins.dvcs.spi.github.GithubCommunicator.setupPostcommitHook(GithubCommunicator.java:249) at com.atlassian.jira.plugins.dvcs.service.remote.CachingCommunicator.setupPostcommitHook(CachingCommunicator.java:199) at com.atlassian.jira.plugins.dvcs.service.RepositoryServiceImpl.addOrRemovePostcommitHook(RepositoryServiceImpl.java:436) at com.atlassian.jira.plugins.dvcs.service.RepositoryServiceImpl.enableRepository(RepositoryServiceImpl.java:396) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) at java.lang.Thread.run(Thread.java:680) Caused by: org.eclipse.egit.github.core.client.RequestException: Not Found (404) at org.eclipse.egit.github.core.client.GitHubClient.createException(GitHubClient.java:516) at org.eclipse.egit.github.core.client.GitHubClient.sendJson(GitHubClient.java:600) at org.eclipse.egit.github.core.client.GitHubClient.post(GitHubClient.java:679) at org.eclipse.egit.github.core.service.RepositoryService.createHook(RepositoryService.java:919) at com.atlassian.jira.plugins.dvcs.spi.github.GithubCommunicator.setupPostcommitHook(GithubCommunicator.java:246)

Verification

To verify which user the DVCS is attempting to authenticate as when accessing GitHub, the following can be done:

  1. Retrieve the current Access Token from the database:

    1 SELECT "ACCESS_TOKEN" from "AO_E8B6CC_ORGANIZATION_MAPPING"

    ℹ️ This is for PostgreSQL and may require changing for different DBMS.

  2. Check this against the GitHub User API to verify which user the token belongs to:

    1 curl -H "Authorization: token <token from the previous SQL>" https://api.github.com/user

    ℹ️ Curl may require installing, and can be downloaded from curl.haxx.se.

  3. Verify if that user is an administrator of the repository JIRA is attempting to connect to. For example, the below identifies the user as captain.planet:

    1 2 3 4 5 { "login": "captain.planet", "id": 123456, ... }

Cause

The user account that is logged into GitHub or BitBucket does not have administrator permissions to the repository.

⚠️ You must be logged in as the admin user in the same browser that JIRA is logged into.

Resolution

  1. Log into JIRA and GitHub/BitBucket (ensuring you're logged in as the owner or an administrator of the repository).

  2. Regenerate the Access token for the repository in the Manage DVCS Accounts screen.

Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.