This topic describes how to add a Target Group to your Environment. Target Groups are a collection of Targets that allow you to bulk serve Flag variations to the Targets defined in the Target Group.
You can group Targets into a group either by selecting individual targets, or by defining rules to automatically map Targets to the Target Group. For example, you could add individual targets [email protected] and [email protected] to be part of a QA Users Target Group, or you could set a rule that all users with emails ending with @harness.io are to be part of the QA Users Target Group.
Perform the following steps to create a target group:
In Feature Flags, click Target Management, then click Target Groups.
Click + Target Group.
In Create a Target Group, enter a Name for your target group and click Create.
Once you have created a Target Group, you need to add Targets to it.
Option 1: Add Individual Targets to a Target Group
Perform the following steps to add Targets to a Target Group:
Select a Target group and click Edit.
In Rules, click Edit Rules.
In Individual Targets, in Include the following, select the targets that you want to include in your Target Group.
In Individual Targets, in Exclude the following, select the targets that you want to exclude from your Target Group.
Once you are done, click Save.
Option 2: Add Targets to a Target Group Based on Conditions
In addition to targeting individual users, Harness Feature Flags also allows you to target a group of users based on the conditions. You can add conditions by constructing rules as the following:
an attribute, which defines the scope of the flag's impact, such as only impacting an email address.
a user value, which identifies a user or resource by a value you specify, such as @harness.io.
an operator, which sets differentiating characteristics of the attribute, such as limiting the attribute to emails that end with certain extensions.
The following operators are supported:
Operator
Attribute Type
Definition
starts with
string
string prefix match
ends with
string
string suffix match
contains
string
substring match
equals
number or string
matches the string or number
equals (sensitive)
number or string
matches the string and is case-sensitive. For example, the string HELLO is different from the string hello.
in
target group names
user is included or excluded by the targeting rules for the named target groups.
Perform the following steps to add Targets to a Target Group based on the rules:
Select a Target Group and click Edit.
In Rules, click + Check for condition and include target to segment.
Enter an attribute, operator, and values for the segment. You can add multiple rules to your Target Group. Here is an example of a rule that serves true to all users whose email address ends with @harness.io. To write this rule, specify the attribute as email, the operator as ends with, and the user value as harness.io.
Once you are done, click Save to apply the rule.
Option 3: Add Targets from Target Settings
You can use Target Settings to include or exclude Targets from the Target Group. Perform the following steps to include or exclude Targets from the Target Settings:
In Feature Flags, in Target Management, select Targets.
In Target Settings, click the Target Groups tab.
Click Add Target to Target Group.
Select the Target Group from the list and click Add.The Targets are added to the Target Groups.
Step: Add Target Group to a Flag
Click on the Target Group to which you want to add a Flag.
Click Add to Flag.
In Add Target Group to Flag, select the Flag and variation.
Click Add. The Flags using the selected Target Group are listed.