This is my YAML code, which selects an agent based on specified demands and the agents' user capabilities. In this example, it checks whether the agent has the 'myCustomCapability' capability or not.
pool:
name: MyPool
demands:
- myCustomCapability # exists check for myCustomCapability
My use case is to pick an agent that does not have this user capability. How can I achieve this here?
Refer to this doc about Yaml Pool schema
Checking for the existence of a capability (exists) and checking for a specific string in a capability (equals) are the only two supported operations for demands.
The Pool demands field only supports exists and equals operations.
I am afraid that Azure DevOps doesn't support non-exists operation when defining the Agent Pool demands for the time being.
For a workaround, you can manually add an additional User-defined capabilities for the agent which doesn't have the user capability.
Then you can use the exists operation to filter the agent which has the additional user capability.
For example:
pool:
name: MyPool
demands:
- anotherCapabilities # exists check for anotherCapabilities
I can fully understand your requirement. You can submit a suggest ticket in the site: Developer Community to report this feature.