To download the artifact from repo

download_artifact powershell 6 years, 3 months ago
$ErrorActionPreference = 'Stop' $S3Name=$args[0] $EnvName=$args[1] if ($EnvName -eq "master") { $SecurePassword = cat "C:\Program Files (x86)\Jenkins\cred\mysecurestring.txt" | convertto-securestring Write-Output "Changes is goning to be appied to $EnvName.pol-dev.projects.epam.com" } Elseif ($EnvName -eq "trunk") { $SecurePassword = cat "C:\Program Files (x86)\Jenkins\cred\mysecurestring_trunk.txt" | convertto-securestring Write-Output "Changes is goning to be appied to $EnvName.pol-dev.projects.epam.com" } Elseif ($EnvName -eq "qa") { $SecurePassword = cat "C:\Program Files (x86)\Jenkins\cred\mysecurestring_qa.txt" | convertto-securestring Write-Output "Changes is goning to be appied to $EnvName.pol-dev.projects.epam.com" } Else { Write-Output "Environment not exist - $EnvName" exit 1 } $User = "\Administrator" $cred = New-Object System.Management.Automation.PSCredential -ArgumentList $User, $SecurePassword $objForRemote = @{} $objForRemote.Artifact=$($env:Artifact) $objForRemote.S3Name=$($S3Name) Invoke-Command -ComputerName "$EnvName.int.polaris-epam.com" -Credential $cred -ArgumentList $objForRemote -ScriptBlock { $objForRemote = $args[0] if (-not(Test-Path -Path "C:\TMP\")) { New-Item -Path "C:\TMP\" -ItemType directory } cd "C:\TMP\" Remove-Item * -Force -recurse aws s3 cp s3://pol-dev-archives/$($objForRemote.S3Name)/$($objForRemote.Artifact)/ . --recursive }
1159
Posted By