Bitbucket code references
Read time: 2 minutes
Last edited: Aug 21, 2023
This topic explains how to use the
ld-find-code-refs utility with Bitbucket code references 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.
To set up Bitbucket Pipes, you must have the following prerequisite:
- A Bitbucket Pipelines configuration file. To create one, navigate to the Pipelines section of your Bitbucket repository.
- An API access token with write permissions for the
code-reference-repositoryresource, either through the built-in Writer role or a custom role. To learn more, read API access tokens and Code reference actions.
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.
To set up the Bitbucket Pipes configuration:
- Create a new Pipeline configuration in your Bitbucket repository.
- Configure the Pipeline to run on
defaultconfiguration. Include the following variables:
LD_ACCESS_TOKEN: This secured variable should be your API access token.
LD_PROJ_KEY: This should be your LaunchDarkly project key. Find it in Account settings, then Projects.
Here's an example of a minimal Pipeline configuration:
You can copy and paste the following code into a blank Pipelines configuration if you have set the
LD_ACCESS_TOKEN environment variables as repository variables:
pipelines:default:- step:script:- pipe: launchdarkly/ld-find-code-refs-pipe:2.11.2environment:LD_ACCESS_TOKEN: $LD_ACCESS_TOKENLD_PROJ_KEY: $LD_PROJ_KEY
To learn more about repository variables, read Atlassian's documentation.
- 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.