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    Documentation

Bitbucket Pipes

Overview

This topic explains how to use the ld-find-code-refs utility with Bitbucket Pipes to create code references in LaunchDarkly.

You can use the ld-find-code-refs utility with Bitbucket Pipelines to automatically populate code references in LaunchDarkly. To do this, you must create a Pipes configuration using LaunchDarkly's code reference pipe.

Prerequisites

To set up Bitbucket Pipes, you have the following prerequisite:

  • A Bitbucket Pipelines configuration file. To create one, navigate to the Pipelines section of your Bitbucket repository.
  • A personal API access token with writer permissions. To learn more, read Personal API access tokens.

Personal API tokens can also use custom roles

Alternatively, you can give the access token access to a custom role with the code-reference-repository resource specifier.

To learn more, read Custom roles.

Setting up the Pipes configuration

To set up the Bitbucket Pipes configuration:

  1. Create a new Pipeline configuration in your Bitbucket repository.
  2. Configure the Pipeline to run on push using the default configuration. Include the following variables:
  3. LD_ACCESS_TOKEN: This secured variable should be your personal API access token.
  4. LD_PROJ_KEY: This should be your LaunchDarkly project key.

Here's an example of a minimal Pipeline configuration:

An example Pipeline configuration.

An example Pipeline configuration.

You can copy and paste the following code into a blank Pipelines configuration if you have set the LD_PROJ_KEY and LD_ACCESS_TOKEN environment variables 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

To learn more about repository variables, read Atlassian's documentation.

  1. Confirm that the pipeline is working by creating a new pull request with the workflow file and visiting the Pipelines page on your repository's webpage. If your pipeline fails, there may be a problem with your configuration. To investigate, check 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

LD_ACCESS_TOKEN

Required.

A LaunchDarkly personal access token with writer-level access, or access to the code-references custom role resource.

Supply this as a secured environment variable.

LD_PROJ_KEY

Required.

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

LD_EXCLUDE

Optional.

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

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

LD_CONTEXT_LINES

Optional.

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

If < 0, no source code is sent to LaunchDarkly.

If 0, only the lines containing flag references are sent.

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

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

LD_BASE_URI

Optional.

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

LD_DEBUG

Optional.
Enables verbose default logging. Defaults to false.

LD_DELIMITERS

Optional.

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: [" ']`.


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.