Functions/Stop-BMRelease.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
 function Stop-BMRelease 
{
    <#
    .SYNOPSIS
    Cancels a release.
 
    .DESCRIPTION
    The `Stop-BMRelease` function cancels a BuildMaster release. It calls the `Releases_CancelRelease` native API endpoint.
 
    .EXAMPLE
    Stop-BMRelease -Session $session -Application 11 -Number 1.1
 
    Demonstrates how to cancel a release. In this case, the `1.1` release of the application whose ID is `11` is cancelled.
 
    .EXAMPLE
    Stop-BMRelease -Session $session -Application 'BuildMaster Automation' -Number 1.1
 
    Demonstrates how to cancel a release. In this case, the `1.1` release of the `BuildMaster Automation` application is cancelled.
    #>

    [CmdletBinding()]
    param(
        [Parameter(Mandatory=$true)]
        [object]
        # The session to use when connecting to BuildMaster. Use `New-BMSession` to create session objects.
        $Session,

        [Parameter(Mandatory=$true)]
        [int]
        # The ID of the application whose release should be cancelled.
        $ApplicationID,

        [Parameter(Mandatory=$true)]
        [string]
        # The release number, e.g. 1, 2, 3, 1.0, 2.0, etc.
        $Number,

        [string]
        # The reason for cancelling the release.
        $Reason
    )

    Set-StrictMode -Version 'Latest'
    Use-CallerPreference -Cmdlet $PSCmdlet -SessionState $ExecutionContext.SessionState

    $parameter = @{
                    Application_Id = $ApplicationID;
                    Release_Number = $Number;
                    CancelledReason_Text = $Reason
                }

    Invoke-BMNativeApiMethod -Session $Session -Name 'Releases_CancelRelease' -Parameter $parameter -Method Post
}