Skip to content

Instantly share code, notes, and snippets.

@mcncl
Last active May 28, 2024 00:34
Show Gist options
  • Save mcncl/a015a65a867098c7c452c2c6569577b8 to your computer and use it in GitHub Desktop.
Save mcncl/a015a65a867098c7c452c2c6569577b8 to your computer and use it in GitHub Desktop.
Get download URLs of artifacts from a pipeline's latest Buildkite build
#!/bin/sh
ORG="test"
PIPELINE="testing"
URL="https://api.buildkite.com/v2/organizations/$ORG/pipelines/$PIPELINE/builds/"
# Parse the response using jq to extract the "number" field from the first element
LATEST_BUILD_NUMBER=$(http -A bearer --auth "$TOKEN" GET "$URL" | jq -r '.[0] | .number')
# Print the build_number
echo "Latest build Number: $LATEST_BUILD_NUMBER"
response=$(http -A bearer --auth "$TOKEN" GET "$URL/$LATEST_BUILD_NUMBER/artifacts")
# Parse the response using jq to extract the download_url fields
download_urls=$(echo "$response" | jq -r '.[] | .download_url')
# Print the download_urls array
echo "$download_urls"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment