Integrating JIRA with Bitbucket Cloud and GitHub

Bitbucket Cloud is Atlassian's cloud-based code repository service. It provides public and private code repositories, with support for both Git and Mercurial. It provides a great option for organizations that want to move to DVCS, but do not want to deal with the infrastructure overhead.

In this recipe, we will look at how to integrate our on-premise hosted JIRA with Bitbucket in the cloud.

Getting ready

Since we will be using Bitbucket in this recipe, you need to have a Bitbucket account (both Git and Mercurial repositories will work). If you do not have one, you can sign up for a free account at https://bitbucket.org.

How to do it...

The first step is to create a new consumer in Bitbucket for JIRA, which will generate the consumer key and secret, as follows:

  1. Log in to your Bitbucket account.
  2. Navigate to Bitbucket settings | OAuth.
  3. Click on the Add consumer button under OAuth consumers.
  4. Enter a name for the new OAuth consumer. The name you enter here will be displayed when JIRA requests access authorization, so you should use a name that is easily understandable, such as Atlassian JIRA.
  5. Click on Save, and this will generate the consumer details we need for the next step:
    How to do it...

Once we have created the new consumer, the next step is to enter the consumer key and secret details into JIRA, as follows:

  1. Navigate to Administration | Applications | DVCS accounts.
  2. Click on the Link Bitbucket Cloud or GitHub account button.
  3. Select Bitbucket Cloud as the Host option.
  4. Enter the Bitbucket account name, the OAuth key, and the OAuth secret details generated from the consumer we just created.
  5. Click on Add to link JIRA to Bitbucket Cloud.

Once JIRA has established a connection to Bitbucket Cloud, you will be prompted to grant JIRA access to your Bitbucket Cloud account. Make sure the consumer name (in bold) is the same as the consumer we created, and then click on Grant access:

How to do it...

How it works...

JIRA uses OAuth as the authorization mechanism to retrieve data from Bitbucket. With OAuth, the application that retrieves data is called the consumer, and the application that provides data is called the provider.

Each consumer needs to be registered with the provider, which generates a key or secret pair. We performed the registration in our first step by adding a new consumer in Bitbucket:

How it works...

If you do not see the Commits tab or section, make sure you have the View Development Tools project permission.

Note

By default, members of the Developers project role have the View Development Tools permission.

There's more...

As you might have already seen during the setup process, JIRA also supports GitHub, both the standard cloud version and the enterprise on-premise version. To integrate with GitHub, you follow the same steps. However, while setting up DVCS accounts, you need to select GitHub instead of Bitbucket.

With GitHub, you will also need the consumer key and secret, generated when you register a new application in GitHub. You can register the application as follows:

  1. Log in to your GitHub account.
  2. Navigate to Account Settings | OAuth applications.
  3. Select the Developer application tab.
  4. Click on Register new application, and enter a name.
  5. Enter JIRA's URL for both the Homepage URL and Authorization callback URL.
  6. Click on Register application.

After you have registered the application, a new client key and secret pair will be generated for JIRA to use. You then just need to go to JIRA's DVCS account section, and select GitHub as the host when linking a new DVSC account to JIRA.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset