Thursday, September 11, 2008

Referencing properties and environment variables with Teamcity

Teamcity allows you to define system properties and environment variables in lots of places. However, I always forget exactly how to reference them in my Nant scripts. So, here's a cheater version for System.Properties and Environment Variables in Nant scripts: Here are some example variables from a Team City project. Below this list, I'll show how they are referenced
  • DotNetFramework1.1_Path is defined under Agents, System Properties as DotNetFramework1.1_Path
  • SVNHOME is defined under Agents, Environment Variables as SVNHOME. Note it is referenced as 'SVNHOME' in the get-variable function. The quotes being the key
  • tc-logdir is listed as env.tc-logdir under the Build Configuration, Environment Variables. Note when referenced in the script, the env. is dropped and is referenced in quotes
  • proptest is listed as proptest under the Build Configuration, System Properties
Here's a simple target that echo's these values and shows how they are referenced. What is nice about teamcity in this regard is, you don't have to pass any variables to your nant script on the command line. They are automatically available to your Nant runner. Happy Scripting!

3 comments:

Andre said...

thanks! just what I needed.

Steve said...

Glad it helped - I've cleaned the post up a bit now for better readability too

House 9 said...

Thanks!

helped me out as well - I am a little surprised this is not included in the TeamCity documentation.