Search code examples
tfsbuild-definition

Use user-defined variables in build definition demands


In TFS 2015 and later, is it possible to resolve a user-defined variable in the build definition demands?


Context

A build definition requires certain software A on its build agent, so I set the an custom agent capability A = path/to/A.

I want to use this path in my build definition and make sure that the build definition uses the correct path before starting a build.

Since TFS does not support referencing the values of agent capabilities inside steps of a build definition or release definition, I'm trying to create a workaround. I don't want to use the custom environment variable on the build machine since I want to avoid the additional build step which is required to pass the env variable to TFS build steps.

The planned workaround

  1. Having a variable SoftwareA in build definition containing path/to/A which can be used by the build steps.
  2. In build definition -> general -> demands check if A equals $(SoftwareA).

However $(SoftwareA) seems not to be resolved by TFS and instead is taken literally.


Solution

  • No, unfortunately the variable is never expanded outside the build/release environment.

    So you need to change the demand value manually to match the path you defined in agent capabilities.

    That means add demands A equals path/to/A.

    There is a user voice here to suggest this feature, but it's archived. You can submit a new user voice again to suggest this feature.