Organizations that utilize CircleCI to power their continuous integration and delivery understand the benefits of deploying early and often: reduced risk, fewer conflicts, and faster value for customers. Pairing CI/CD with feature flags allows modern development teams and organizations to write and ship code at their own pace while still ensuring that customers and users get the best possible experience.

Code References

We’ve built a new feature called Code References that surfaces all instances of a LaunchDarkly feature flag in your code. We’ve built Code References in way that does not allow LaunchDarkly access to your source code by utilizing a utility called ld-find-code-refs that is available as an orb. This ld-find-code-refs utility scans your deployed code and sends snippets back to LaunchDarkly to easily ensure that the flags are where you expect them and to give confidence that they’re removed when flags are no longer necessary.

The LaunchDarkly orb

The LaunchDarkly orb uses ld-find-code-refs to send updated snippets back to LaunchDarkly every time you do a deploy. By baking in Code References into your standard deployment workflows using orbs, everyone on your team has the confidence that you’ve wrapped all new code in a flag when you deploy and that you’ve safely removed all feature flags when you’ve released a new feature to all customers and users.

Easy integration

This is an example of a standard orb configuration:

version: 2.1
  launchdarkly: launchdarkly/ld-find-code-refs@1.0.0
      - launchdarkly/find-code-references:
          debug: true
          access_token: '${LD_ACCESS_TOKEN}'
          repo_type: github
          repo_url: YOUR_REPO_URL
          context_lines: 3

In this example, we have a configuration with the the repo_type set to GitHub, and the repo_url set to a GitHub URL. We recommend configuring these parameters so LaunchDarkly is able to generate reference links to your source code.

Learn more about LaunchDarkly’s Code References here and get the orb here.

Wrapping up

At LaunchDarkly, we deploy to production multiple times a day using CircleCI. As we’ve grown, we wanted to make it easier for development teams to ensure that the code they’re deploying is safely wrapped in feature flags when it’s deployed and to help teams remove feature flags after a feature has been exposed to 100% of all users and customers. With Code References, it’s easy to determine which files in your Git repositories reference your feature flags, and it makes cleanup and removal of technical debt easy.