Agent requirements are defined on the Agent Requirements tab of the Stage Options dialog.
These are a set of rules that determine which agents are eligible to run a stage. All rules must evaluate to true for an agent to be selected for the stage. See Expression Objects for details of the types of expressions that can be used in these rules.
For example, you might:
[$Agent.Hostname$] [Does not Equal] [agent-x]
,[$Agent.Hostname$] [Equals] [%DeployToAgentHostName%]
, or[$Agent.AspNetCore.App.9.0.4.Path$] [Exists]
.In addition to defining requirement rules, you can also configure how agents are prioritised when multiple agents are available that meet the requirements.
You can specify an expression in the Agent Priority field to determine which agent should be selected first. The expression typically refers to a property that varies between agents.
By default, this value is: $Agent.Priority.Value$
, the value for which can be specified in the Agent Properties list.
When choosing among eligible agents:
The default behaviour is to select the agent with the highest capacity, calculated by subtracting the number of running stages from the concurrent stage limit:
Capacity = Concurrent Stage Limit - Number of Running Stages
If multiple agents have the same capacity, the one with the highest priority value (based on the priority expression) is selected. Priority values are compared numerically or alphabetically.
You can reverse the priority order by ticking the Select agent in reverse order of priority checkbox.
If the Priority overrides capacity option is enabled:
Scenario | What Happens |
---|---|
Multiple agents meet all requirements | System compares their capacity first. |
Agents have different capacities | Agent with highest capacity is selected. |
Agents have same capacity | Agent with highest priority value (as per expression) is selected. |
"Reverse order of priority" is ticked | Agent with lowest priority value is preferred. |
"Priority overrides capacity" is enabled | Agent with highest priority value is selected first, ignoring capacity. |
Equal priority values when overridden | Agent with highest capacity is used as tiebreaker. |