Skip to content

Commit c2bb16d

Browse files
committed
Add CircleCI image download script
1 parent 80c7c7d commit c2bb16d

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env bash
2+
3+
# Usage: $ ./circleci_image_artifact_download.sh JOB_NUMBER DEST_DIR
4+
5+
# The job number is shown on the job page in the navigation breadcrumbs under 'Job':
6+
# ... Job
7+
# ... > test-baselines (123456)
8+
# It's also shown in the URL: '.../jobs/123456/...'
9+
10+
set -euo pipefail
11+
12+
# Arguments
13+
JOB_NUMBER="${1:-}"
14+
DEST_DIR="${2:-.}"
15+
16+
# Check if job number is provided
17+
if [[ -z "$JOB_NUMBER" ]]; then
18+
echo "CircleCI job number required. Usage: $0 <job-number> [destination-directory]"
19+
exit 1
20+
fi
21+
22+
mkdir -p "$DEST_DIR"
23+
cd "$DEST_DIR"
24+
25+
# Get list of artifact URLs (filtering for .png files not containing 'diff')
26+
artifact_urls=$(curl https://circleci.com/api/v2/project/github/plotly/plotly.js/$JOB_NUMBER/artifacts \
27+
| grep -oE "https.*png" \
28+
| grep -v "diff")
29+
30+
# Download each artifact
31+
echo "$artifact_urls" | while read -r url; do
32+
echo "Downloading $url..."
33+
curl -s -L -O "$url"
34+
done
35+
36+
echo "✅ All PNG artifacts saved to: $DEST_DIR"

0 commit comments

Comments
 (0)