Trigger Bitbucket Pipelines with Jira Cloud Automation

With Jira Automation us project administrators have a powerful tool to add automations to your Jira projects like create, assign and edit issues. Furthermore, we are able to set conditions so that actions will only be executed when an issue meets a certain criteria. Currently, there are only a few automations available for external systems such as Microsoft Teams or Slack. If you need your own integration you have to use Web Requests. In this post I’d like to demonstrate how you can trigger a Bitbucket Pipeline based on a Jira Issue Event. Let’s imagine we are working in a Software Development team and we’ve recently started to automate our work. We are of course using the Atlassian Stack with Jira and Bitbucket and we’d like to connect both applications so that every time an Issue gets transitioned to “Testing” we want to trigger a Bitbucket pipeline.

Setup

Lets assume we already have a Jira Cloud project and a Bitbucket pipeline setup. If you want to know more about it, please read the documentation:

Trigger Bitbucket Pipelines with Jira Cloud Automation

Prerequisites

To configure Jira Automations you need to have the specific permissions. For Classic Projects you need the Administer Project permission, for Next-gen Projects you need to be within the Administrator Role.

Depending on which project type you use, you’ll find the Automation page here:

Classic Project

  • Project settings → Automation

Next-gen Project

  • Project settings → Apps → Project Automation

One more thing we need to look at before we start is to find out how the use the Bitbucket API. In this link you’ll find all information about the data we need to send to the API to trigger a pipeline for a branch.

Trigger Bitbucket Pipelines with Jira Cloud Automation

Automation

1. Trigger

As sketched above we want to trigger the pipeline every time an issue gets transtioned into the status “Testing”. In this case we should use the Issue Transitioned trigger.

Trigger Bitbucket Pipelines with Jira Cloud Automation

2. Notification

Pick the From Status and To Status.

You can choose several statuses with both fields.

When you’ve saved this configuration we can choose to pick a Condition first, to limit the scope of issues. In our case we’ll simply pick a new Action right away.

From the list of options we pick Send web request which is within the Notifications list.

Trigger Bitbucket Pipelines with Jira Cloud Automation

To configure the Send web request we need the following information:

  • Workspace: Team name or your account name
  • Repository Slug: Repository name
  • POST Data:

{
      “target”: {
          “ref_type”: “branch”,
          “type”: “pipeline_ref_target”,
          “ref_name”: “master”
      }
}

One way to trigger pipelines is by specifying the branch for which you want to trigger a pipeline. The specified branch will be used to determine which pipeline definition from the bitbucket-pipelines.yml file will be applied to initiate the pipeline. The pipeline will then do a clone of the repository and checkout the latest revision of the specified branch.

With this information we can configure our Web request:

Trigger Bitbucket Pipelines with Jira Cloud Automation

For authorization, please read this documentation, here you’ll different ways to authenticate.

Trigger Bitbucket Pipelines with Jira Cloud Automation
Über den Autor
Jan Szczepanski
For Jan Szczepanski, what counts most when optimizing processes is the lasting effect. This is how the expert for project and process management successfully leads companies into the future – this applies both to customers and to Jodocus. As an Atlassian specialist, he not only optimizes his customers' processes down to the last detail. As a marketing enthusiast, he is also ensures the expressive charisma of Jodocus: As CMO, he is responsible for all aspects of marketing – from branding to the entire communication of Jodocus' products, consulting services and solutions. In doing so, he applies the expertise he has gained over many years in improving communication and collaboration structures – with passion, ambition and success.