Compare commits

...

3 Commits

Author SHA1 Message Date
1a891324e3 Update LATEST_VERSION to 3355.v388858a_47b_33-5
Some checks failed
Build container image / build (push) Has been cancelled
Check upstream updates / check-updates (push) Has been cancelled
2026-01-09 02:19:03 +00:00
55d837beb0 Improve update script with redirection support and robustness. 2026-01-09 02:18:38 +00:00
467f2f6a1a Prevent "null" versions in update check. 2026-01-09 02:16:34 +00:00
2 changed files with 34 additions and 7 deletions

View File

@ -1 +1 @@
null
3355.v388858a_47b_33-5

View File

@ -1,12 +1,39 @@
#!/bin/bash
LATEST_VERSION=$(curl -s https://api.github.com/repos/jenkinsci/docker-agent/releases/latest | jq -r '.tag_name')
CURL_EXIT_CODE=$?
if [ $CURL_EXIT_CODE -ne 0 ] || [ -z "$LATEST_VERSION" ]; then
echo "Failed to retrieve the latest version"
TEMP_JSON=$(mktemp)
trap 'rm -f "$TEMP_JSON"' EXIT
API_URL="https://api.github.com/repos/jenkinsci/docker-agent/releases/latest"
HTTP_CODE=$(curl -fsL -o "$TEMP_JSON" -w "%{http_code}" "$API_URL")
if [ $? -ne 0 ]; then
echo "Error: Network request failed."
exit 1
fi
if [ "$LATEST_VERSION" != "$(cat LATEST_VERSION)" ]; then
echo "$LATEST_VERSION" > LATEST_VERSION
if [ "$HTTP_CODE" != "200" ]; then
echo "Error: API returned HTTP $HTTP_CODE"
if [ -s "$TEMP_JSON" ]; then
echo "Response body:"
cat "$TEMP_JSON"
fi
exit 1
fi
LATEST_VERSION=$(jq -r '.tag_name // empty' "$TEMP_JSON")
if [ -z "$LATEST_VERSION" ] || [ "$LATEST_VERSION" == "null" ]; then
echo "Error: Failed to extract tag_name from response."
exit 1
fi
if [ -f LATEST_VERSION ]; then
CURRENT_VERSION=$(cat LATEST_VERSION)
else
CURRENT_VERSION=""
fi
if [ "$LATEST_VERSION" != "$CURRENT_VERSION" ]; then
echo "New version found: $LATEST_VERSION (Old: $CURRENT_VERSION)"
echo "$LATEST_VERSION" > LATEST_VERSION
else
echo "Already at latest version: $LATEST_VERSION"
fi