How to access system properties in rake-runner?

I need the values of a handful of vcs related datapoints in my rake file.  Specifically, vcsroot.url and vcsroot.branch.  But they seem not to be available at rake script runtime.

I even print out the complete list of available variables, like so: ENV.each {|key, value| puts "#{key} = #{value}" }.  But it does not show either of those values.

I use ENV['name'] to get at the environment variables.  How do I get to the system properties?

I was under the impression that all the system and environment variables were passed to the runners automatically.  Is that not true?  Or is it just some subset perhaps?  Must I define a build parameter manually for any other values?

4 comments
Comment actions Permalink

Hi,

I am wondering about the same thing. Seems only env variables are passed and other props are not available for the rake script. Since you've posted this 2 years ago I wonder if you've made some progress with this or not ;)

0
Comment actions Permalink

Unfortunately I never did figure it out.

0
Comment actions Permalink

No trouble. I've just tried to dig a little bit deeper and found out that for NAnt, teamcity uses an extension dll (JetBrains.BuildServer.NAntLoggers.dll) that actually inject all of these properties as NAnt properties. The responsible class is called NAntPropertiesSetter that has an InjectProperties method which is doing the trick.

I just need to somehow replicate this behavior with the rake/ruby runner and that's it. I don't know yet how, but I like the challenge already

0
Comment actions Permalink

if you're still interested, here is a hack:

you will need java_properties gem (gem install java_properties on the agent(s) machine(s))

in your rakefile you can then:

require 'java_properties'
tcprops = JavaProperties::Properties.new(ENV['TEAMCITY_BUILD_PROPERTIES_FILE'])

#tcprops hashtable now contains alll of the available props
tcprops.each { |key,value| puts "#{key} = #{value}" }

0

Please sign in to leave a comment.