Flag dependencies

3 minute read

Flag dependencies allow a flag value to be dependent on another flag value. This can be very useful when you want to make sure a feature is only rolled out if another feature is present.

Your feature may require a specific backend API version, for example. You create Flag A for displaying this feature and Flag B for using the specific backend API version. You can then add a boolean condition to Flag A such that Flag A is TRUE whenever Flag B is TRUE.

Flag dependency example
Figure 1. An example of flag dependency where Flag A is TRUE whenever Flag B is TRUE.

Adding a flag dependency

You can configure a flag to be dependent on another flag. Both flags must be in the same app.

To add a flag dependency:

  1. From the CloudBees Feature Management Home page, select Flags in environments, and then select an environment.

  2. Select a flag, and then select the Configuration tab.

  3. Select Add a new condition.

  4. Select flag from the dropdown menu.

    Select flag option
    Figure 2. Selecting flag from the dropdown menu.
  5. From the dropdown menu next to flag, select the flag you want your flag to depend on, and then select the flag value. Add any other desired conditions.

  6. From the top right corner of the main screen, select one of the following Save Configuration options (select the arrow to display hidden options):

    • Save Configuration (requires Full access): Saves the flag configuration, but does not turn Configuration on. The configuration is only activated when Configuration on is set. Refer to Managing feature releases to turn the configuration on.

    • Save & Activate Configuration (requires Full access): Saves the flag configuration, and turns Configuration on.

    • Request Changes: Saves the flag configuration and sends a request to all administrators for approval. The configuration is not activated, even if scheduled to do so. Refer to Requesting approval for flag configurations for more information.

Removing a flag dependency

You can remove your dependent flag condition from the flag configuration.

To remove a flag dependency:

  1. From the CloudBees Feature Management Home page, select Flags in environments, and then select an environment.

  2. Select the flag, and then select the Configuration tab.

  3. Select the trash can icon to the right of the flag dependency condition.

    Selecting the trash can icon to remove a flag dependency.
    Figure 3. Selecting the trash can icon to remove a flag dependency.
  4. From the top right corner of the main screen, select one of the following Save Configuration options (select the arrow to display hidden options):

    • Save Configuration (requires Full access): Saves the flag configuration, but does not turn Configuration on. The configuration is only activated when Configuration on is set. Refer to Managing feature releases to turn the configuration on.

    • Save & Activate Configuration (requires Full access): Saves the flag configuration, and turns Configuration on.

    • Request Changes: Saves the flag configuration and sends a request to all administrators for approval. The configuration is not activated, even if scheduled to do so. Refer to Requesting approval for flag configurations for more information.

Deleting feature flags that have dependencies

Feature flags cannot be deleted if another feature flag is depending on it. If you attempt to delete a feature flag which has dependencies, the dependent flags are listed on the flag cleanup screen. Refer to Deleting feature flags for more information.

Select each flag in the cleanup screen list and remove the flag dependency.

Runtime workflow

In the following example, Flag B is dependent on Flag A.

Table 1. Flag B is dependent on Flag A.
server-side SDK client-side SDK

When Flag B is evaluated, Flag A is also evaluated.

When Flag B is evaluated, Flag A is also evaluated.

Flag B context extends to Flag A.

Flag A and Flag B are both frozen after Flag B evaluation.

Impression handler is called for both Flags A and B.

Impression handler is called for both Flags A and B.

CloudBees Feature Management blocks creation of any configuration that would lead to a circular dependency.