diff options
| author | TitanSnow <[email protected]> | 2017-05-26 20:49:38 +0800 |
|---|---|---|
| committer | TitanSnow <[email protected]> | 2017-05-26 20:49:38 +0800 |
| commit | c66fed229a272a1459570ee8444ef8515e352c74 (patch) | |
| tree | 59c73a411a2b23fe50600c3a8e2f5d29b0c0d7c3 /scripts | |
| parent | efd3e77d397fc3ffa2364f6e7b8132f48e28d926 (diff) | |
walk history to find a successful build
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/getpb.ps1 | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/scripts/getpb.ps1 b/scripts/getpb.ps1 index 9fa789be3..77bcb318d 100644 --- a/scripts/getpb.ps1 +++ b/scripts/getpb.ps1 @@ -28,19 +28,24 @@ Function Get-AppVeyorArtifacts{ $headers = @{ 'Content-type' = 'application/json' } - $obj = Invoke-RestMethod -Method Get -Uri "$apiUrl/projects/$Account/$Project" -Headers $headers - $jobId = $null + $obj = Invoke-RestMethod -Method Get -Uri "$apiUrl/projects/$Account/$Project/history?recordsNumber=13" -Headers $headers + $job = $null if([environment]::Is64BitOperatingSystem){ - $jobId = 1 + $job = 1 }else{ - $jobId = 0 + $job = 0 } - $jobId = $obj.build.jobs[$jobId].jobId - $artifacts = Invoke-RestMethod -Method Get -Uri "$apiUrl/buildjobs/$jobId/artifacts" -Headers $headers - $artifactFileName = $artifacts[0].fileName - if($artifactFileName -ne "xmake.exe"){throw "artifact not found"} - $localArtifactPath = "$DownloadDirectory\$artifactFileName" - Invoke-RestMethod -Method Get -Uri "$apiUrl/buildjobs/$jobId/artifacts/$artifactFileName" -OutFile $localArtifactPath + Write-Output $obj.builds | ForEach-Object { + $jobId = $_.jobs[$job].jobId + $artifacts = Invoke-RestMethod -Method Get -Uri "$apiUrl/buildjobs/$jobId/artifacts" -Headers $headers + $artifactFileName = $artifacts[0].fileName + if($artifactFileName -eq "xmake.exe"){ + $localArtifactPath = "$DownloadDirectory\$artifactFileName" + Invoke-RestMethod -Method Get -Uri "$apiUrl/buildjobs/$jobId/artifacts/$artifactFileName" -OutFile $localArtifactPath + return + } + } + throw 'artifact not found' } writeLogoLine ' _ ' |
