Pass variable to puppet on commandline

puppet, teamcity, windows

Solution

I think you'd want to do this via custom facts, which this conversation addresses.

Problem

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

Original source