I'm trying to get TeamCity to trigger a deployment with puppet via the commandline using puppet.bat on Windows.
In Teamcity I'm calling this using a Command Line runner, with Command executable: C:\Program Files (x86)\Puppet Labs\Puppet\bin\puppet.bat Command parameters: apply myexample.pp
What I would like to do is also pass the build number from TeamCity as well so I can use this within myexample.pp
Is this possible?
UPDATE: Code used for Custom Fact which was the accepted answer below.
require 'open-uri'
$uri = URI.parse("http://teamcity/guestAuth/app/rest/buildTypes/id: <BUILDID>/builds/status:SUCCESS/number")
$version = $uri.read
Facter.add("latestbuildversion") do
setcode do
$version
end
end
To pass a value through the command line it needs to be an environment variable, prefixed by FACTER_.
So, FACTER_foo will turn into $::foo.