1

I am trying to set up an API-key to be a global variable that is accessible across all of my TFS2015 Builds. Since TFS2015 seems to lack this feature, I am attempting to use a system environment variable on the build server that is then referenced in the build definitions.

According to Microsoft's documentation, this should be possible. So I have set up a system variable (call it APIKey) on the build server and referenced it within the arguments of a build step using the standard syntax (i.e. "ApiKey=$(APIKey)"). However, instead of replacing the variable with the API-key in the system variable it is trying to use $(APIKey) as the value and causing the build to fail.

It also occurred to me that this custom environment variable would instead be set somewhere in the build agent folder itself but, after some poking around, I'm not sure where or how I would do that.

Are either of these things actually doable?

2
  • Did you reboot the build agent machine after add the system variable? Commented May 10, 2016 at 0:32
  • I did not, will give that a try Commented May 10, 2016 at 13:03

1 Answer 1

2

Following are my steps to achieve this:

  1. Create a system variable on build agent machine: enter image description here

  2. Restart the build agent machine.

  3. Use the variable in build definition. Here I use cmd task as an example and use the $(testvar) as its argument: enter image description here

The task will read the value from system variable as following: enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

I don't think you'd need to restart the entire machine -- just the agent service. System environment variables are copied when the process starts, so restarting the process should pick up the new values.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.