3

In the administration area for TFS Build Agents, is it possible to set environment variables that will be used when running builds?

build agent ui

Most of my searches for information on this turn up results on how to do the opposite - make use of an existing environment variable in a bulid definition or agent requirement. What I want to do is to, from this UI, set the value of an environment variable, that will then be available for all builds running on the agent.

Tomas Aschan
  • 58,548
  • 56
  • 243
  • 402
  • Sounds like this is what you are (roughly) trying to achieve? http://stackoverflow.com/questions/39206539/how-to-get-an-agent-user-capability-in-tfs-build-task – Pero P. Oct 21 '16 at 20:27
  • @pero: Yes - well, at least, if I could do that, I could do this. But that question seems to imply that it's impossible... :( – Tomas Aschan Oct 24 '16 at 06:10

2 Answers2

2

There isn't any way to achieve this feature. An alternative way would be creating the environment variable on the build agent machine, then this variable would be available for all the builds running on the agent. However, the disadvantage is that all the agents on this machine will read this environment variable.

Eddie Chen - MSFT
  • 29,708
  • 2
  • 46
  • 60
  • 1
    It also has the disadvantage that I have to manually connect to each machine and set the environment variable, which is the problem I was trying to solve. Thanks for the clarification, though. – Tomas Aschan Oct 28 '16 at 06:55
1

Every agent has two sets of capabilities that define the features of the agent.

User capabilities are properties you can add to an agent to help identify a specific agent or a specific feature that it supports. These capabilities can be demanded in a release definition, so that Release Management automatically chooses the appropriate agent when executing a deployment. The capabilities can also be used to pass agent-specific values that are required by a deployment (such as the path of a tool or framework you have installed on the server). For more details, see Select the agent for a task phase.

System capabilities are built-in features of the agent such as the versions and locations of applications it can access when deploying artifacts. These capability settings cannot be changed.

You can use this in release definition, however just as jessehouwing said in that link you cannot access the capabilities from PowerShell through a variable unfortunately. And since build task acctually invoked by powershell script. So this can't be achieved for now.

Community
  • 1
  • 1
PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62