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 variable values via the command line, use the PrjVar ( pv ) or PSVar ( psv ) arguments for the project and project suite variables respectively. Variable values you pass via the command line are temporary.
A commented list of all configuration options can also be generated by running puppet with '--genconfig'.
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.
I think you'd want to do this via custom facts, which this conversation addresses.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With