Functions/Get-ArtifactoryParameters.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
<#PSScriptInfo
 
.VERSION 1.0.0
 
.GUID
 
.AUTHOR Artsiom Krot
 
.PROJECTURI https://github.com/artyom-krot/PS.JfrogArtifactory
 
.RELEASENOTES
 
 
Script file name:
 
    Get-ArtifactoryParameters.ps1
 
.DESCRIPTION
 
    The script is an integral part of PS.JfrogArtifactory solution (https://github.com/artyom-krot/PS.JfrogArtifactory)
 
#>


function Get-ArtifactoryParameters {
    [CmdletBinding()]
    param()

    if ([string]::IsNullOrEmpty($script:artifactoryUrl)) {
        Write-Error "Variable artifactoryUrl is not defined. Please use cmdlet Set-ArtifactoryConnection first!'";
        Exit 1
    } 
    elseif ([string]::IsNullOrEmpty($script:artifactoryUser)) {
        Write-Error "Variable artifactoryUser is not defined. Please use cmdlet Set-ArtifactoryConnection first!'";
        Exit 1
    }
    elseif ([string]::IsNullOrEmpty($script:artifactoryUserToken)) {
        Write-Error "Variable artifactoryUserToken is not defined. Please use cmdlet Set-ArtifactoryConnection first!'";
        Exit 1
    }
    else {
        @{
            serverUri  = $script:artifactoryUrl
            userName   = $script:artifactoryUser
            userToken  = $script:artifactoryUserToken
        }
    }
}