Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# 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
@Biswa96

This comment has been minimized.

Copy link

commented Apr 29, 2018

For example the environment variable jobToWait: 'Environment: test=1' will be:

  • For Ubuntu: jobToWait: 'image: Ubuntu'
  • For Windows: jobToWait: 'image: Visual Studio 2017'
@JamesYangLim

This comment has been minimized.

Copy link

commented Aug 23, 2018

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
You can’t perform that action at this time.