Functions/Build/Resume-BambooBuild.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
28
29
30
31
32
33
34
35
36
37
<#
.SYNOPSIS
    Resumes or Continues a single suspended build.
.DESCRIPTION
    If -ExecuteAllStages parameter is specified it continues a paused or
    manually suspended build.
.PARAMETER BuildKey
    Mandatory - Key for the suspended/rested build
.PARAMETER ExecuteAllStages
    Optional - Switch to instructs bamboo to finish all further stages
.EXAMPLE
    Resume-BambooBuild -BuildKey 'PRJ-PLANKEY-2'
.EXAMPLE
    Resume-BambooBuild -BuildKey 'PRJ-PLANKEY-2' -ExecuteAllStages
#>

function Resume-BambooBuild {
    [CmdletBinding(DefaultParameterSetName="ByBuildKey")]
    param(
        [Parameter(Mandatory,ParameterSetName="ByBuildKey")]
        [ValidatePattern('\w+-\w+-\d+')]
        [string]$BuildKey,

        [switch]$CustomRevision,
        [switch]$ExecuteAllStages
    )

    $params=@{}
    if ($CustomRevision) {
        $params.customRevision=""
    }
    if ($ExecuteAllStages) {
        $params.executeAllStages=""
    }
    Invoke-BambooRestMethod -Resource "queue/$BuildKey" -Method Put -UriParams:$params |
    Expand-BambooResource -ResourceName 'restQueuedBuild'
}