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
- If you haven't already, create a LaunchDarkly access token with the correct permissions.
- 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.
- The pipeline step should run on push, using the
defaultconfiguration. 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_ACCESS_TOKEN environment variables have been configured as repository variables:
pipelines default step script pipelaunchdarkly/ld-find-code-refs-pipe1.0.0 environment LD_ACCESS_TOKEN$LD_ACCESS_TOKEN LD_PROJ_KEY$LD_PROJ_KEY
- 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.
The code reference pipe may be configured with additional environment variables to enable more functionality.
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.
A LaunchDarkly project key. The flag parser will search this project for code references in this project.
A regular expression (PCRE) defining the files, file types, and directories which the flag finder should exclude.
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
Set the base URL of the LaunchDarkly server for this configuration. Defaults to https://app.launchdarkly.com
Enables verbose default logging. Defaults to
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: