LaunchDarkly integration

The functionality of Release's LaunchDarkly integration and how to set it up

Release's LaunchDarkly integration allows you to have a pristine, isolated LaunchDarkly environment to use for testing.

Sharing feature flags between multiple environments can cause testing and reliability issues. Release solves this problem by creating a new LaunchDarkly environment each time you deploy a new Release environment and storing the SDK key, mobile key, and client key as environment variables your application can access.

Release handles creating and deleting LaunchDarkly environments with little configuration needed.

Set up the integration

Navigate to the Integrations tab for your account.

Each field in the set-up form is required. Except for the Access Token field, you can use the defaults provided.

  • Project Key: This is the key for the project you want your environments created under. The default value is default, as LaunchDarkly always has a project with the key default.

  • Access Token: This is the token for the account you would like to create environments under in LaunchDarkly. You can create or find the access token under Account Settings -> Authorization. All access tokens start with api-.

  • Environment Variables: The remaining fields define the names of the environment variables Release will use to store the various API keys from LaunchDarkly. You can change these names to anything you like. Keys are stored as encrypted K8s secrets.

You will need the LaunchDarkly access token to set up your SDK client so that you can choose variations of flags in your application.

Once you have saved these configurations, Release will attempt to use your access token to connect to your LaunchDarkly account. If that works, the integration is ready to go! If not, you'll see errors and can correct any mistakes you have made.

Using the LaunchDarkly integration

The integration consists of two parts, both of which are automated and handled by Release.

  • Pre-deployment step: The LaunchDarkly integration will add a task to each of your deployments to create the feature flag environment.

  • Pre-delete step: When you delete an environment, a step will be injected that cleans up by deleting the environment in LaunchDarkly.

Pre-deployment step

The pre-deployment step will create an environment in LaunchDarkly the first time you deploy a space or new configuration.

The environment variables you specified during set up will be populated and exposed to your containers via K8s secrets.

You can then use these environment variables in your code to access your feature flags as you normally would.

Pre-delete step

The pre-delete step is invoked when a Release environment is removed, whether manually through the UI or when a pull request is merged or closed. The LaunchDarkly integration will remove the corresponding LaunchDarkly environment automatically when the Release environment is removed.


Below are some examples of how to consume the environment variables to use the LaunchDarkly integration.

Rails: Setting up LaunchDarkly SDK client

In this example, we will configure the LaunchDarkly SDK client with the specific API key for your environment. This example is based on the Ruby SDK reference.

When running locally, you can use the dotenv gem ( to set your LaunchDarkly environment variables to test values.

  • Install the Ruby SDK gem.

  • Create a file in config/initializers/launchdarkly_client.rb.

  • Copy the code below into config/initializers/launchdarkly_client.rb.


  #Uncomment this section if you would like to use the LaunchDarklyApi gem (
  #This is NOT the gem for using the Ruby LaunchDarkly SDK (
  #Most people do not need to use the LaunchDarkly Rest API defined here:, but
  #instead just want to use the SDK to interact with the feature flags in their specific environment.
  #If you would like to use the LaunchDarkly Rest API, make sure to install the gem besides uncommenting these lines.


LaunchDarklyApi.configure do |config|
  config.api_key['Authorization'] = access_token
  config.debugging = true


##To use the LaunchDarkly Ruby SDK, you will need the specific SDK key.
##In this example, I'm setting up `LDClient` under the `Rails.configuration` so it's accessible anywhere
##in your Rails project.
Rails.configuration.ld_client =['LAUNCHDARKLY_ENV_SPECIFIC_SDK_KEY'])

Example of using the LDClient you defined above in your Rails application

test_flag = Rails.configuration.ld_client.variation("test-flag", {key: ""}, false)

Last updated