Unable to Connect to a Private Repository using the DVCS Plugin

Still need help?

The Atlassian Community is here for you.

Ask the community

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:

The following appears in the atlassian-jira.log:

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:

    SELECT "ACCESS_TOKEN" from "AO_E8B6CC_ORGANIZATION_MAPPING"

    (info) 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:

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

    (info) 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:

    {
      "login": "captain.planet",
      "id": 123456,
      ...
    }

Cause

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

(warning) 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.

Last modified on Mar 21, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.