Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Teamcity and Rake: Where are the tc system properties?

Tags:

rake

teamcity

I'm converting some of my NAnt build scripts over to rake. Does anyone know how to access the system properties (e.g. build.number) inside my rake scripts? Is the Teamcity rake plugin even injecting them? I can't seem to find the doco.

like image 643
Dane O'Connor Avatar asked Feb 28 '23 10:02

Dane O'Connor


1 Answers

Please refer to the list of predefined properties. In the rake script and in the ruby code these variables are available via environment, for example add this in the rakefile:

puts 'Build number: ' + ENV['BUILD_NUMBER']

If you want to see all the available properties, put the following code:

ENV.each {|key, value| puts "#{key} = #{value}" }

Run the build from TeamCity and inspect the log, in the All messages mode you'll see the available properties.

If you want to pass some other property which is available in TeamCity or is defined in the agent.conf file, you should add it in the Properties and environment variables tab of the Rake Configuration in ther Web UI.

For example, you want to pass system.CUSTOM property defined in the agent.conf file. Click the Add new variable link, specify CUSTOM as a name and %system.CUSTOM% as a value. Now in the rakefile you can access it as ENV['CUSTOM'].

So, the idea is to pass the properties you need via environment if they are not in the list of the predefined properties already passed as environment variables.

like image 92
CrazyCoder Avatar answered Mar 06 '23 19:03

CrazyCoder