Public/Teamcity/Publish-TeamcityArtifact.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function Publish-TeamcityArtifact
{
    [CmdletBinding()]
    param (
        # The artifact you wish to publish
        [Parameter(
            Mandatory = $true,
            Position = 0
        )]
        [string]
        $ArtifactPath,

        # The target directory to publish the artifact to (optional)
        [Parameter(
            Mandatory = $false,
            Position = 1
        )]
        [string]
        $TargetDirectory
    )
    if ((Test-Path $ArtifactPath) -ne $true)
    {
        Write-Error "Artifact path $ArtifactPath is not valid"
    }
    Write-Verbose "Publishing $ArtifactPath as an artifact"
    Write-Host "##teamcity[publishArtifacts '$ArtifactPath'$(if($TargetDirectory){"=> $TargetDirectory"})]"
}