LaunchDarkly Developer Documentation

Get started in under 30 minutes.
LaunchDarkly provides feature flags as a service for Java · Python · Ruby · Go · Node.js · PHP · .NET. Control feature launches -- who sees what and when -- without multiple code deploys. Easy dashboard for phased rollouts, targeting and segmenting.
Need more help? write us at support@launchdarkly.com

Get Started    Guides

Bitbucket pipes

The ld-find-code-refs utility can be used with Bitbucket Pipelines to automatically populate code references in LaunchDarkly. We'll create a Pipes configuration using LaunchDarkly's code reference pipe

Initial setup

  1. If you haven't already, create a LaunchDarkly access token with the correct permissions.
  2. Create a new pipelines configuration in your selected Bitbucket repository. If you don't already have a pipeline configuration file, you'll need to create a new Pipelines configuration, by visiting the Pipelines section on your repository's webpage.
  3. The pipeline step should run on push, using the default configuration. The access token configured earlier should be included as a secured variable named LD_ACCESS_TOKEN, in addition to a variable named LD_PROJ_KEY, set to the desired LaunchDarkly project key. Here's an example of a minimal Pipeline configuration:

The following code may be copied and pasted into a blank pipeline configuration, assuming the LD_PROJ_KEY and LD_ACCESS_TOKEN environment variables have been configured as repository variables:

pipelines:
  default:
    - step:
        script:
          - pipe: launchdarkly/ld-find-code-refs-pipe:1.0.0
            environment:
              LD_ACCESS_TOKEN: $LD_ACCESS_TOKEN
              LD_PROJ_KEY: $LD_PROJ_KEY
  1. Once your pipeline has been created, the best way to confirm that the pipeline is executing successfully is to create a new pull request with the workflow file, and verify that the newly created pipeline is succeeding, by visiting the Pipelines page on your repository's webpage. If your pipeline fails, there may be a problem with your configuration. To investigate, dig into the pipeline's logs to view any error messages.

Pipeline configuration

The code reference pipe may be configured with additional environment variables to enable more functionality.

Variable
Description
Required

LD_ACCESS_TOKEN

A LaunchDarkly personal access token with writer-level access, or access to the code-references custom role resource. Should be supplied as a secured environment variable.

yes

LD_PROJ_KEY

A LaunchDarkly project key. The flag parser will search this project for code references in this project.

yes

LD_EXCLUDE

A regular expression (PCRE) defining the files, file types, and directories which the flag finder should exclude.

Examples: vendor/, vendor/.*, .*\.css

no

LD_CONTEXT_LINES

The number of context lines above and below a code reference for the flag parser to send to LaunchDarkly.

If < 0, no source code will be sent to LaunchDarkly.

If 0, only the lines containing flag references will be sent.

If > 0, will send that number of context lines above and below the flag reference.

A maximum of 5 context lines may be provided. Defaults to 2

no

LD_BASE_URI

Set the base URL of the LaunchDarkly server for this configuration. Defaults to https://app.launchdarkly.com

no

LD_DEBUG

Enables verbose default logging. Defaults to false

no

LD_DELIMITERS

Specifies additional delimiters used to match flag keys. Must be a non-control ASCII character. If more than one character is provided in delimiters, each character will be treated as a separate delimiter. Will only match flag keys with surrounded by any of the specified delimeters. This option may also be specified multiple times for multiple delimiters. By default, only flags delimited by single-quotes, double-quotes, and backticks will be matched. Default: [" ']`.

no


Bitbucket pipes


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.