-
Notifications
You must be signed in to change notification settings - Fork 17
How can I integrate psake with Team City?
TeamCity 6.5 includes a bundled PowerShell runner.
If you are using a previous version of TeamCity, you may use the PowerShell runner plug-in; you can download the plug-in’s binaries here. See Installing Additional Plugins for general help on installing plug-ins for TeamCity.
Add a new build step and select PowerShell runner.
- Set your run mode (x86 or x64)
- Set your working directory (typically the directory where your build scripts are located)
- Select Source code mode in Script input
- Insert
& .\psake.ps1
to run default build - Set additional command line parameters
-NoProfile -ExecutionPolicy Unrestricted
Now you are ready.
If you need parameterize your build script, you can use the predefined TeamCity parameters and variables. Pass in the parameters as a hash table using the following syntax:
& .\psake.ps1 -parameters @{build_number=%build.number%}
You can pass multiple parameters by separating them with commas:
& .\psake.ps1 -parameters @{build_number=%build.number%,personal_build=%build.is.personal%}
If you are using PowerShell v3.0 or greater, you can get all of the TeamCity parameters into a hash with the following code in your .ps1 file:
$TCParams = ConvertFrom-StringData (Get-Content $env:TEAMCITY_BUILD_PROPERTIES_FILE -Raw);
After this code executes, you can access any TeamCity parameter as
$TCParams['parameter.name']
e.g. $TCParams['build.number']
There is a TeamCity module included in the Psake Contrib project which provides tighter integration with TeamCity. For example, you can report the currently-executing task to TeamCity by inserting the following lines into your build script (after the Properties section):
Include .\teamcity.psm1
TaskSetup {
TeamCity-ReportBuildProgress "Running task $($script:context.Peek().currentTaskName)"
}