Last active
May 28, 2024 00:34
-
-
Save mcncl/a015a65a867098c7c452c2c6569577b8 to your computer and use it in GitHub Desktop.
Get download URLs of artifacts from a pipeline's latest Buildkite build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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