Target groups

3 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.

You can create unlimited target groups in CloudBees Feature Management, and each target group can have any number of attributes, allowing you to finely tune a given audience for a feature flag.

Once you’ve created a target group, select it in the audience settings of multiple flags to give them all the same targeting. Any updates to the target group definition instantly apply to all flags using it in their audience.

You can 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, you can modify the target group to roll out the new features to external users.

Target groups overview

Creating and modifying a target group, and adding a target group to a flag configuration.

Watch the video
Target groups can use custom properties to define user segments. Refer to Custom properties for more information.

CloudBees Feature Management includes built-in targeting using the format of rox.<attribute name>, as described in Table 1.

Table 1. Built-in target group attributes
Attribute NameNotes

rox.language

Two letter language code, e.g., "en," "es," or "fr"

rox.platform

OS name, e.g., "iOS" or "Android"

rox.screen_height

Screen height in pixels

rox.screen_width

Screen width in pixels

If you are using a client-side SDK, and the value of a custom property changes while the app is running, such as after a user signs in, you may need to use Rox.unfreeze(). Refer to Flag update flow for more information.

Creating a target group

  1. From the CloudBees Feature Management Home page, in the left pane, select Target groups.

  2. Select Create target group from the upper-right corner of your screen.

  3. Enter a Name and an optional Description.

  4. Select an attribute from the Conditions dropdown menu, which includes both built-in attributes and any Custom properties you have created.

  5. Select an operator and enter a value, if appropriate. You may create multiple conditions.

  6. Select Create group.

Your target group is created and is now available to configure flags. Refer to Audiences for more information.

Select the environment name below the target group definition to see which feature flags use this target group.

Modifying a target group

You can modify a target group even if it is actively used in a flag configuration in the Production environment.
  1. From the CloudBees Feature Management Home page, in the left pane, select Target groups, and then select a target group.

  2. Modify the Conditions. You can also modify the optional description, but not the name.

  3. Select Update Group. If the target group is in active use in a production environment flag, a warning displays. Select Update if you are sure you want to update the target group.

Your target group is updated accordingly.

Deleting a target group

You cannot delete a target group if it is used in a flag configuration.
  1. From the CloudBees Feature Management Home page, in the left pane, select Target groups, and then select a target group.

  2. Select Delete, and then select Delete.

Your target group has been deleted.

Regex Syntax

You can run regex matching for custom properties from type String, as displayed in the following target group example:

image

The underlying code on the SDK is:

JavaScript
C#
Java
Go
Ruby
Python
PHP
C
C++
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;
}
boolean regexMatch(String str, String pattern){
   int options = 0;
   Pattern r = Pattern.compile(pattern, options);
   Matcher m = r.matcher(str);
   return m.find()
}
import (
  "regexp"
)
boolean regexMatch(String str, String pattern){
  matched, _ := regexp.MatchString(pattern, str)
  return matched;
}
# In the above Example
#    str is the email property value
#    pattern is "@cloudbees\.com$"
matched = !Regexp.new(pattern, 0).match(src).nil?
import re

# In the above Example
#    str is the email property value
#    pattern is "@cloudbees\.com$"
re.search(pattern, src, 0)
preg_match(pattern, src);

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);