Skip to content

Instantly share code, notes, and snippets.

@IlyaFinkelshteyn
Last active October 12, 2020 05:02
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save IlyaFinkelshteyn/79af78657660e118b15d3ab9d62ab8a1 to your computer and use it in GitHub Desktop.
Save IlyaFinkelshteyn/79af78657660e118b15d3ab9d62ab8a1 to your computer and use it in GitHub Desktop.
# Job 'Environment: test=1' uploads artifact. Others wait while it finishes and download it.
clone_script:
- cmd: echo skip clone
environment:
ApiKey:
secure: SlDEDtAKuvsy+VErEuc/4DxdhPeKu2WRqvYzEh/fiH4=
TimeOutMins: 2
jobToWait: 'Environment: test=1'
matrix:
- test: 1
- test: 2
install:
- ps: |
if ($env:APPVEYOR_JOB_NAME -eq $env:jobToWait) {
Get-Date > date.txt
Push-AppveyorArtifact .\date.txt # upload artifact for otjer job to download
}
if ($env:APPVEYOR_JOB_NAME -ne $env:jobToWait) {
write-host "Waiting for job `"$env:jobToWait`" to complete"
$headers = @{
"Authorization" = "Bearer $ApiKey"
"Content-type" = "application/json"
}
[datetime]$stop = ([datetime]::Now).AddMinutes($env:TimeOutMins)
[bool]$success = $false
while(!$success -and ([datetime]::Now) -lt $stop) {
$project = Invoke-RestMethod -Uri "https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG" -Headers $headers -Method GET
$jobToWaitJson = $project.build.jobs | where {$_.name -eq $env:jobToWait}
$success = $jobToWaitJson.status -eq "success"
$jobToWaitId = $jobToWaitJson.jobId;
if (!$success) {Start-sleep 5}
}
if (!$success) {throw "Job `"$env:jobToWait`" was not finished in $env:TimeOutMins minutes"}
if (!$jobToWaitId) {throw "Unable t get JobId for the job `"$env:jobToWait`""}
Start-FileDownload https://ci.appveyor.com/api/buildjobs/$jobToWaitId/artifacts/date.txt
}
build: off
test: off
@JamesYangLim
Copy link

Hi.
I used matrix and did "Push-AppveyorArtifact" from 'ubuntu', then tried "Start-FileDownload" from 'Visual Studio 2017'.
Got error status code 404.

Do I need Token Api to get the file? How do I specify that for "Start-FileDownload" command?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment