Target groups

4 minute read

A target group is a set of users having the same properties or attributes, such as email domain, language, geolocation, device, or software version.

Create an unlimited number of target groups in the CloudBees platform. Each target group configuration can have nested conditions for complex logic and unlimited attributes, allowing you to finely tune a given audience for a feature flag.

Multiple flags can all have the same targeting, and updating a single target group definition applies to all flags that use the target group in their flag configuration.

Set up a target group for internal testing only, for example, and use it across multiple flags to test new features. Once internal testing is complete, modify the target group to roll out the new features to external users.

Create target groups using custom or built-in properties defined in the code. All target group configurations are scoped to the application where they are defined. They are not shared across applications.

To learn more about defining and using target groups refer to Configure feature flags.

Use built-in properties

You can use built-in properties when defining target group conditions.

For a full list of available built-in properties, refer to built-in properties.

Use regular expressions

Regular expression (regEx) matching is an Operator option in target group creation.

Use regular expressions
Figure 1. An example of using regEx matching in the target group UI.

The underlying code on the SDK is:

Go
Java
JavaScript
JavaScript SSR
.NET/C#
Node.js
PHP
Python
React Native
Ruby
import ( "regexp" ) boolean regexMatch(String str, String pattern){ matched, _ := regexp.MatchString(pattern, str) return matched; }
boolean regexMatch(String str, String pattern){ int options = 0; Pattern r = Pattern.compile(pattern, options); Matcher m = r.matcher(str); return m.find(); }
function regexMatch(str, pattern) { var regex = new RegExp(pattern, ""); var match = regex.exec(str); return match ? true : false; }
function regexMatch(str, pattern) { var regex = new RegExp(pattern, ""); var match = regex.exec(str); return match ? true : false; }
bool regexMatch(String str, String pattern){ RegexOptions options = 0; Match match = Regex.Match(str, pattern, options); return match.Success; }
function regexMatch(str, pattern) { var regex = new RegExp(pattern, ""); var match = regex.exec(str); return match ? true : false; }
preg_match(pattern, src);
import re # In the above example # str is the email property value # pattern is "@cloudbees\.com$" re.search(pattern, src, 0)
function regexMatch(str, pattern) { var regex = new RegExp(pattern, ""); var match = regex.exec(str); return match ? true : false; }
# In the above example # str is the email property value # pattern is "@cloudbees\.com$" matched = !Regexp.new(pattern, 0).match(src).nil?

The following provides more information:

expect(parser.evaluateExpression('match("111", "222"')).toEqual(false); expect(parser.evaluateExpression('match("22222", ".*")')).toEqual(true); expect(parser.evaluateExpression('match("22222", "^2*$")')).toEqual(true); expect(parser.evaluateExpression('match("[email protected]", ".*(com|ca)")')).toEqual(true); expect(parser.evaluateExpression('match("[email protected]", ".*car\\.com$")')).toEqual(true); expect(parser.evaluateExpression('match("US", ".*IL|US")')).toEqual(true); expect(parser.evaluateExpression('match("US", "IL|US")')).toEqual(true); expect(parser.evaluateExpression('match("US", "(IL|US)")')).toEqual(true);

Manage target groups in the UI

Create, update, and delete configured target groups for an application.

Access target groups

You can search in and sort the list of target groups.

To access target groups:

  1. Select Feature management  Target groups.

  2. (Optional) Search for a specific target group, by entering all or part of a target group name into Search.

  3. (Optional) Select an option in Sort by to sort the target group list by either ASCENDING or DESCENDING alphanumerical sort order.

The target groups are displayed according to your search or sort criteria.

Create a target group

Use custom properties or built-in attributes (ROX PROPERTIES) to define user segments. You can also create targeting dependent on other target groups.

You can only create nested statements based on target group options as long as there are no circular dependencies on other target groups.
  1. Select Feature management  Target groups.

  2. Select Create target group.

  3. Enter a Name, an optional Description, and select one of the following conditions:

  4. (Optional) Select the Property condition.

    1. Select a Property name from the options.

    2. Select an Operator from the options (including regular expression matching).

    3. Enter a Value, if the property type is not a Boolean.

      To add multiple values when the equals one of operator is selected, select the Enter/Return key after entering each value.
  5. (Optional) Select the Target group condition.

    1. Select a Matches …​ logical operator option.

    2. Select a Target group from the options.

  6. (Optional) Select Add condition to add more conditions.

    1. Select one of the following logical operator options:

      • Matches all the following (AND operator)

      • Matches any of the following (OR operator)

        All subsequent conditions use the same logical operator.
    2. Configure either a Property or a Target group condition.

  7. Select Save when all conditions are added.

Your target group is created, and listed in Target groups.

Select the next to a condition to remove it. However, you must have at least one condition.
Example target group
Figure 2. An example target group created with multiple conditions

Update a target group

  1. Select Feature management  Target groups.

  2. Select Vertical ellipsis next to the target group you want to delete.

  3. Select Edit, and then make the desired updates.

  4. Select Save.

The target group is updated accordingly.

Delete a target group

Delete any unused target group.

Before you can delete a target group, you must first remove all references to it in all flag configurations.
A deleted target group is permanently removed from the application and all linked environments. Deletion is irreversible.

To delete a target group:

  1. Select Feature management  Target groups.

  2. Select Vertical ellipsis next to the target group you want to delete.

  3. Select Delete.

  4. Remove all references to the target group in all flag configurations, if you have not already done so.

    1. Select the Down icon next to each displayed environment.

    2. For each flag in each environment, select Edit configuration.

      Remove target group
      Figure 3. Select Edit configuration to remove the target group reference.
    3. Remove the target group reference.

    4. Return to the target group you want to delete and select Delete.

  5. Select Delete.

The selected target group is deleted and removed from the target group list.

To define the properties used for targeting, refer to Properties and custom properties.