A PowerShell module that facilitates build script interaction with TeamCity Build Agents
Note: Before proceeding, ensure you have the following pre-requisites:
Open a PowerShell prompt and run the command below to install the module from the PowerShell Gallery:
Install-Module `
-Name PSTeamCity-BuildLog `
-Scope CurrentUser `
Import-Module PSTeamCity-BuildLog
For local development, clone the repository and and import the module folder into a PowerShell session directly:
Import-Module 'C:\path\to\repository\src\PSTeamCity-BuildLog'
These Cmdlets will only produce output when running as part of a TeamCity build, unless otherwise noted.
Use the
Test-TeamCity
Cmdlet to determine if the current script is running within a TeamCity environment.
Returns $true
or $false
, based on whether the current scope is believed to be running on a TeamCity Build Agent.
Example Usage:
if (Test-TeamCity) {
# Execute TeamCity-specific logic here
}
Escapes strings so that they can be safely used in other Cmdlets without breaking integration with the TeamCity build log.
Writes an informational message to the build log. TeamCity treats these messages differently than normal output.
Writes a message to the build log that indicates a problem with the build. TeamCity treats these messages differently than normal output.
Writes a message to the build log indicating the beginning of a new block. Capturing the return value will allow the block to be closed when piped to Remove-TeamCityBlock
.
- Any output that is emitted between
New-TeamCityBlock
andRemove-TeamCityBlock
is considered to be as contents of the block. - The contents of a block can be collapsed in the TeamCity build log.
- Blocks can be nested within other blocks by specifying unique values for the
-Name
parameter.
$blockOuter = New-TeamCityBlock -Name "Outer"
Write-Host "This message is part of the outer block!"
$blockInner = New-TeamCityBlock -Name "Inner"
Write-Host "This message is contained in a nested block!"
$blockInner | Remove-TeamCityBlock
Write-Host "Now we're back to the outer block again!"
$blockOuter | Remove-TeamCityBlock
Writes a message to the build log indicating the ending of an existing block.
Closing a block will close any nested blocks as well.