How To download an Artifact from AppVeyor without PowerShell

Besides the poplpular CI services Travis circleci there is AppVeyor which fills the Windows gap:

Continuous Delivery service for Windows

We cannot use Downloading AppVeyor build artifacts (PowerShell - basic example) due to the lack of PowerShell on our download server we "translated" the script to GNU Bash.

Declaring variables

PowerShell:

$apiUrl = 'https://ci.appveyor.com/api'

Bash:

API_URL="https://ci.appveyor.com/api"

GET a JSON file

PowerShell:

$project = Invoke-RestMethod -Method Get -Headers @{ "Content-Type" = "application/json" } -Uri "$uri"

Bash:

$PROJECT=$(curl -sS --header "Content-type: application/json" "$URI")

Parse JSON file

PowerShell (built-in):

$jobId = $project.build.jobs[0].jobId

Bash (with jq)

JOB_ID=$(echo $PROJECT | jq -r '.build.jobs[0].jobId')

Note: You can download jq (a lightweight and flexible command-line JSON processor) here

With httpbin you can easily experiment with this setup on your own:

$ curl -sS https://httpbin.org/get | jq -r '.url'
https://httpbin.org/get

For more detailed explanation in case you have more complex scenarios I highly recommend this post HTTP to HTTP with bash, curl and jq

Good luck with your migration!

Show Comments