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.
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.