So konvertieren Sie das Shell -Skript in das Ansible Playbook
Inputs:
apikey
script:
param (
[string]$apikey
)
copy-item $PSScriptRoot\* -destination 'w:\temp'
$erroractionpreference = 'SilentlyContinue'
new-item -ItemType Directory -path 'w:\Build\Scripts'
new-item -ItemType Directory -path 'w:\Build\QA\EventLogs'
write-host 'apikey: ' $apikey
$LOG_DIR = 'w:\Build'
$LOG_FILE = $LOG_DIR + '\copy_agents' + '_' + $(get-date -format s | foreach {$_ -replace ':','-'}) + '.log'
Start-Transcript -path $LOG_FILE
$VerbosePreference = 'Continue'
start-transcript -Path $LOG_FILE -append
$wc = New-Object System.Net.WebClient
$wc.Headers.Add('X-JFrog-Art-Api', $apikey)
$artiURL = 'https://artifactory.bsc.bscal.com/artifactory/ias/misc/FileList/files.csv'
$localDir = 'W:\Build\files.csv'
$wc.DownloadFile($artiURL,$localDir)
$Files = import-csv W:\Build\files.csv
try {
foreach($file in $Files) {
write-host 'File: ' $file
new-item -ItemType Directory -Path "W:\$($File.local)"
$wc = New-Object System.Net.WebClient
$wc.Headers.Add('X-JFrog-Art-Api', $apikey)
$artifactory_url = 'https://artifactory.bsc.bscal.com/artifactory/ias/misc/' + $file.dir + '/' + $file.file
$localdir = "W:\$($file.local)\$($file.file)"
Write-Output 'artifactory_url: ' + $artifactory_url
$wc.DownloadFile($artifactory_url,$localdir)
if (test-path -Path "w:\$($file.local)\*.zip"){
Expand-Archive -Path $localdir -DestinationPath "W:\$($file.local)"
remove-item -Path $localdir
}
}
Stop-Transcript
}
catch {
$Host.UI.WriteErrorLine("Error while Trying to download Artifacts.")
$Host.UI.WriteErrorLine($_.Exception.Message)
exit
}
naqash ali