> ## Documentation Index
> Fetch the complete documentation index at: https://launchdarkly-preview.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Bitbucket Pipelines

> This topic explains how to create and enable feature flags using Bitbucket Pipelines, a continuous delivery platform that lets your team build, test, and deploy from Bitbucket.

> For the complete documentation index, see [llms.txt](/llms.txt). For the full documentation snapshot, see [llms-full.txt](/llms-full.txt).

<Note title="The Bitbucket Pipelines integration is available to customers on select plans">
  The Bitbucket Pipelines integration is only available to customers on select plans. To learn more, [read about our pricing](https://launchdarkly.com/pricing/). To upgrade your plan, [contact Sales](https://launchdarkly.com/contact-sales/).
</Note>

## Overview

This topic explains how to create and enable feature flags using Bitbucket Pipelines.

The LaunchDarkly integration lets you insert feature flag actions directly into your Pipeline's continuous delivery flow. [Bitbucket Pipelines](https://bitbucket.org/product/features/pipelines) is a continuous delivery platform that lets your team build, test, and deploy from Bitbucket. It exists within Bitbucket, giving you end-to-end visibility from coding to deployment.

We provide two scripts you can add to your pipelines:

* **Create feature flags in your Pipelines build**: This lets you create feature flags within a specified project. The feature flag will be created in all environments for that project.
* **Enable a feature flag in your Pipelines build**: This lets you turn on a specific feature flag for a specific environment within a project.

## Prerequisites

To use the LaunchDarkly Bitbucket Pipelines integration, you must meet the following prerequisites:

* [A Bitbucket account](https://bitbucket.org/account/signup/)
* [Bitbucket Pipelines](https://bitbucket.org/product/features/pipelines) installed on your Bitbucket account

## Create feature flags in your Pipelines build

You can configure a Bitbucket Pipeline step to create a set of feature flags in LaunchDarkly as part of your build process.

To set up your Bitbucket Pipeline with LaunchDarkly:

1. Copy the `create-launchdarkly-flags.sh` shell script from our [Bitbucket repository](https://bitbucket.org/launchdarkly/launchdarkly-pipelines/src).
2. Add `create-launchdarkly-flags.sh` to your Pipelines build configuration.
3. Add two environment variables to your Pipelines settings:
   * `LAUNCHDARKLY_ACCESS_TOKEN`: Copy your API access token from the [Authorizations tab](https://app.launchdarkly.com/settings/authorization) within Account settings.
   * `LAUNCHDARKLY_PROJECT_KEY`: Copy your project key from your [LaunchDarkly Projects tab](https://app.launchdarkly.com/settings/projects) within Account settings.

<Frame caption="The Access tokens section of the Authorization tab.">
  ![The Access tokens section of the Authorization tab.](https://files.buildwithfern.com/https://launchdarkly.docs.buildwithfern.com/docs/0b80c46a1c86bc7c99d2eb1ee5da20a0464cb17a694b2dde353e7e416f365ae2/assets/images/auto/settings-access-tokens.auto.png)
</Frame>

<Warning title="Do not use the LaunchDarkly environment key">
  Be careful to use the LaunchDarkly **project key** in the Bitbucket Pipelines settings, not the environment key. To learn how to find your project key, read [Project keys](/home/account/project#project-keys).
</Warning>

4. Add an `ld-flags.conf` file to your repository and declare flags in it. When your Pipelines build runs, any feature flags you declare in this file is also created in LaunchDarkly.

## Enable a feature flag in your Pipelines build

You can configure a Pipeline step that enables an existing feature flag in an environment as part of your build.

To enable feature flags with Bitbucket Pipelines:

1. Copy the `enable-launchdarkly-flags.sh` shell script from our [Bitbucket repository](https://bitbucket.org/launchdarkly/launchdarkly-pipelines/src).
2. Add `enable-launchdarkly-flags.sh` to your Pipelines build configuration.
3. Add these environment variables to your Pipelines settings:
   * `LAUNCHDARKLY_ACCESS_TOKEN`: Copy your API access token from the [Authorization tab](https://app.launchdarkly.com/settings/authorization).
   * `LAUNCHDARKLY_PROJECT_KEY`: To learn how to find your project key, read [Project keys](/home/account/project#project-keys).
   * `LAUNCHDARKLY_ENVIRONMENT_KEY`: Copy your environment key from your [LaunchDarkly Projects tab](https://app.launchdarkly.com/settings/projects).
   * `LAUNCHDARKLY_FLAG_KEY`: Enter the key for the feature flag you wish to enable.
