Public/Invoke-JenkinsRequest.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
function Invoke-JenkinsRequest {
    [CmdletBinding()]
    param (
        [String] $Resource,
        [String] $Method = "GET",
        [Object] $Body,
        [Hashtable] $Query = @{},
        [String] $ContentType = "application/json",
        [Int] $MaximumRedirectionCount = 0,
        [String] $Username = $script:apiUsername,
        [SecureString] $Password = $script:apiPassword,
        [int] $MaximumAttempts = 3,
        [bool] $TreatRedirectAsSucces = $true
    )

    Invoke-Jenkins  -Resource $Resource `
                    -Method $Method `
                    -Body $Body `
                    -Query $Query `
                    -Form $Form `
                    -ContentType $ContentType `
                    -MaximumRedirectionCount $MaximumRedirectionCount `
                    -Username $Username `
                    -Password $Password `
                    -MaximumAttempts $MaximumAttempts `
                    -TreatRedirectAsSucces $TreatRedirectAsSucces

}