How We Used Feature Flags to Launch CloudBees CI/CD Powered by Jenkins X. And You Can Do It Too.

Written by: Peter Muir
5 min read
Stay connected

Editor's note: This blog post first appeared on CloudBees Feature

CloudBees CI/CD powered by Jenkins X is an automated and opinionated CI/CD as a Service solution for cloud native applications. It takes everything that makes Jenkins X great and gives it to you in a hosted, turnkey way with no overhead services to manage. We announced the preview program at DevOps World in Lisbon recently – you can join the preview program , too.

Leveraging the power of Kubernetes for end-to-end application development, CloudBees CI/CD maximizes the efficiency and speed of the cloud native CI/CD pipeline, with the least possible overhead, for development teams using modern DevOps practices.

Jenkins X and CloudBees CI/CD are not all we have around here, though. CloudBees Feature Management is an advanced feature flagging solution that lets your development teams quickly build and deploy applications without compromising on safety. By providing a gradual release mechanism and a simple way to define target audiences, CloudBees Feature Management allows developers and product managers to optimize features releases and customize the user experience. CloudBees Feature Management gives teams control over features that are in staging, production or any environment you have in your deployment pipeline.

CloudBees CI/CD is powered by the Jenkins X open source project and includes the same features and web UI we include in the CloudBees Jenkins X Distribution today. Over time we will differentiate the proprietary SaaS from the open source project with more enterprise focussed features while continuing to invest heavily in both. We might also want to add a feature early to the CloudBees CI/CD SaaS to get some early feedback before releasing it more widely – behind a feature flag for targeted user testing, of course…

Jenkins X is heavily inspired by the State of DevOps Report and the Accelerate book, both of which advocate short-lived branches as characteristics of high performing teams (something that is definitely borne out by experience!). This means that using different branches for CloudBees CI/CD, the CloudBees Jenkins X Distribution and the open source Jenkins X project was out. Feature flags are the typical solution here as they allow you to continuously merge new features into controller, while keeping them hidden behind a feature flag. You can then enable the feature(s) for certain users when you are ready. We evaluated CloudBees Feature Management and it worked out really well for us.

(CloudBees Jenkins X Distribution product/service is no longer being offered by CloudBees.  Visit  to learn more about the community offering.)

How we used CloudBees Feature Management for feature control

In our React web UI, we take advantage of the CloudBees Feature Management Javascript library which allows us to load the feature flags, with default values specified in the code. As we are using Functional Components in React we can store the feature flags in a react context :

export function <i>createFeatureFlags</i> (): FeatureFlags {

   return {

       devPod: new Rox.Flag(),

       environmentActions: new Rox.Flag(),

       loggedInUserFeature: new Rox.Flag()



export const <b><i>FeatureFlags </i> </b> = <i>createContext</i> (<i>createFeatureFlags</i> ());

and access them as needed. Using the feature flag is as simple as an if statement:

const { environmentActions } = <i>useContext</i> (<b><i>FeatureFlags</i> </b> );

if (environmentActions.isEnabled()) {

   <i>// Dosomething</i> 


Now we can control whether the environment actions are enabled or not from the CloudBees Feature Management UI.

CloudBees Feature Management main control grouping feature is the “environment” and you use a different environment key to address each environment. In order to allow us to change the key without rebuilding the UI containers we added a REST endpoint to the UI backend that exposes the key – and we load that key from an environment variable that is set on the container by Kubernetes.

So far we’ve not needed to add any custom properties as simply being able to enable or disable the feature for an environment has been sufficient.

How we used CloudBees Feature Management to validate new configurations

We quickly ran into a second challenge – how can we easily enable developers to test out new configurations in our playground, without impacting the entire team if the new configuration is not correct? We needed a way to change the configuration for a specific user (or group of users) whilst keeping the existing, tested, configuration for the rest of the team.

Jenkins X is built around GitOps (which allows us to version and audit all of our configuration); the classic way to test out a configuration change in our “playground” is to switch from using the upstream controller branch of the git repo used for GitOps to your personal fork. CloudBees Feature Management was very helpful here as it allowed us to override the default GitOps repo with our personal forks without having to build a custom Admin UI.

Our backend systems are entirely implemented in Go, and luckily CloudBees Feature Management also provides a Go library.

Just as for the frontend, we load the CloudBees Feature Management Environment Key from an environment variable anywhere we want to use CloudBees Feature Management, and then use the Go client to access the value of the feature flag. This time we pass in a custom property “email” so we can allow each developer to specify a different value when they log in:

roxContext := context.NewContext(map[string]interface{}{

  "email": email,


URL := ff.GitURL.GetValue(roxContext)

if URL != "" {

  log.Logger().Infof(" git url is %s", URL)

  url = url + "&#x26;URL=" + URL


We then define an experiment with multiple conditions – and allow people to specify their own URL for the git repo to pull the configuration with.

Where we’ll go next

As we expand the preview program, we hope to use feature flags to differentiate between different groups of users (e.g. internal vs external) and enable/disable features based on the grouping.

CloudBees Feature Management has played a key part in helping us build this new Jenkins X experience as a SaaS, and we plan to improve the integration between the two to make continuous delivery more powerful, and easier than ever going forward.

Stay up to date

We'll never share your email address and you can opt out at any time, we promise.