LaunchDarkly integration

Describes the functionality ReleaseHub offers with its LaunchDarkly integration as well as how to set it up in ReleaseHub.

LaunchDarkly Integration

ReleaseHub's LaunchDarkly integration allows you to have a pristine, isolated LaunchDarkly Environment to use for testing. One of the difficulties you may have when utilizing feature flags is dealing with multiple environments. You can try and share your feature flag environments with multiple staging or pre-production environments, but much like sharing a database between multiple environments is dangerous and can cause testing and reliability issues, so can sharing feature flag environments.
We solve this by creating a new LaunchDarkly environment each time you deploy a new ReleaseHub Environment, while also storing the SDK, Mobile, and Client keys into environment variables that are accessible to your application. Both creation and deletion of LaunchDarkly environments are handled by ReleaseHub, while only requiring a very small amount of configuration.

Setup the Integration

Navigate to the Integrations tab for the account so you can setup the LaunchDarkly Integration.
Click 'Setup' for LaunchDarkly
Each field in the setup form is required, and all but one have defaults you can use.
  • 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 key default.
  • Access Token: This is the token for the account you would like us to create environments under in LaunchDarkly. You can create or find the access token you would like to use in LaunchDarkly, under Account Settings -> Authorization. All access tokens start with api-.
  • Environment Variables: The last three form elements define the names of the environment variables where ReleaseHub will store the appropriate API keys from LaunchDarkly. You may change them to anything you like. You will most likely need the LaunchDarkly access token to setup your sdk client for choosing variations of flags in your application. Upon setting up the environment in LaunchDarkly, ReleaseHub will store the various api keys values in these environment variables. This will allow you container access to the various API keys you need. They are stored as encrypted K8s secrets.
LaunchDarkly Configuration
Once you have saved it, ReleaseHub will attempt to use your Access Token to connect to your LaunchDarkly account. If that works, you're done. The integration is ready to go! If not, you'll see errors and can correct any mistakes you have made.

Utilizing the LaunchDarkly Integration

The integration consists of two parts, both of which are automated and handled by ReleaseHub.
  • 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.
Ephemeral Environment Creation Workflow

Pre-Deployment Step

The Pre-Deployment step is for when you first deploy a space or deploy a new configuration. But, it will only create the environment in LaunchDarkly the very first time it runs.
Environment 'ted422c' was created in LaunchDarkly
Upon successful creation, the environment variables you specified during setup will be populated and exposed to your containers via K8s secrets.
LaunchDarkly Specific Envs as 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 anytime a ReleaseHub Environment is removed, whether that be manually through the UI or upon merge/closure of a pull request. The LaunchDarkly integration will remove the corresponding LaunchDarkly environment automatically upon removal of the ReleaseHub Environment.


Below are some examples of how to consume the environment variables to utilize 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.
#Uncomment this section if you would like to use the 'launchdarkly_api' gem (
#This is NOT the gem for using the Ruby LaunchDarkly SDK (
#Most people do not need to utilize 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 utilize 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
##In order to utilize the LaunchDarkly Ruby SDK, you will need the specific SDK key
##In this example I'm setting up 'ld_client' 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 ld_client you defined above in your Rails application
test_flag = Rails.configuration.ld_client.variation("test-flag", {key: "[email protected]"}, false)
That's all there is to it! Now you can start using your feature flags or if this is an existing app, everything related to querying and getting the current values of your flags should work in any environment.