|
| 1 | +$apiUrl = 'https://ci.appveyor.com/api' |
| 2 | +$token = "$env:DeployApiCode" |
| 3 | +$headers = @{ |
| 4 | + "Authorization" = "Bearer $token" |
| 5 | + "Content-type" = "application/json" |
| 6 | +} |
| 7 | +$accountName = 'thomas694' |
| 8 | +$projectSlug = 'classificationbox-toolkit' |
| 9 | + |
| 10 | +$downloadLocation = "$env:APPVEYOR_BUILD_FOLDER" |
| 11 | +$artifactsPath = "$downloadLocation\artifacts" |
| 12 | +New-Item -ItemType Directory -Force -Path $artifactsPath |
| 13 | + |
| 14 | +# get project with last build details |
| 15 | +$project = Invoke-RestMethod -Method Get -Uri "$apiUrl/projects/$accountName/$projectSlug" -Headers $headers |
| 16 | + |
| 17 | +foreach($job in $project.build.jobs) |
| 18 | +{ |
| 19 | + # get this job id |
| 20 | + $jobId = $job.jobId |
| 21 | + if ($jobId -eq "$env:APPVEYOR_JOB_ID") { continue } |
| 22 | + |
| 23 | + # get job artifacts (just to see what we've got) |
| 24 | + $artifacts = Invoke-RestMethod -Method Get -Uri "$apiUrl/buildjobs/$jobId/artifacts" -Headers $headers |
| 25 | + |
| 26 | + foreach($artifact in $artifacts) |
| 27 | + { |
| 28 | + $artifactFileName = $artifact.fileName |
| 29 | + |
| 30 | + # artifact will be downloaded as |
| 31 | + $localArtifactPath = "$downloadLocation\$artifactFileName" |
| 32 | + |
| 33 | + # download artifact |
| 34 | + # -OutFile - is local file name where artifact will be downloaded into |
| 35 | + # the Headers in this call should only contain the bearer token, and no Content-type, otherwise it will fail! |
| 36 | + Invoke-RestMethod -Method Get -Uri "$apiUrl/buildjobs/$jobId/artifacts/$artifactFileName" ` |
| 37 | + -OutFile $localArtifactPath -Headers @{ "Authorization" = "Bearer $token" } |
| 38 | + } |
| 39 | +} |
| 40 | +Get-ChildItem "$artifactsPath\*.zip" | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name } |
0 commit comments