fix: 使用 jq 以确保可以获取确切的 tag_name.

This commit is contained in:
2025-01-14 09:31:37 +08:00
parent 0f4dd3416d
commit 599c6372d8
2 changed files with 12 additions and 2 deletions

View File

@ -1,4 +1,12 @@
LATEST_VERSION=$(curl -s https://api.github.com/repos/jenkinsci/docker-agent/releases/latest | grep tag_name | cut -d '"' -f 4)
#!/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"
exit 1
fi
if [ "$LATEST_VERSION" != "$(cat LATEST_VERSION)" ]; then
echo "$LATEST_VERSION" > LATEST_VERSION
fi
fi