From a7684fba2286eb1643683c98b18080d8de1cbb69 Mon Sep 17 00:00:00 2001 From: Ellie <4158750+esenmarti@users.noreply.github.com> Date: Tue, 29 Oct 2024 10:23:29 +0100 Subject: [PATCH 1/3] Support version pinning in Windows (#2) --- install.ps1 | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/install.ps1 b/install.ps1 index 0501bea7c3..0491dd54ce 100644 --- a/install.ps1 +++ b/install.ps1 @@ -41,20 +41,24 @@ if ([string]::IsNullOrEmpty($url)) { if($null -eq $version){ $version = "latest" } - $releaseInfoUrl = "https://buildkite.com/agent/releases/$($version)?platform=windows&arch=$arch" - if($beta) { - $releaseInfoUrl = $releaseInfoUrl + "&prerelease=true" + if ($version -eq "latest") { + $releaseInfoUrl = "https://buildkite.com/agent/releases/$($version)?platform=windows&arch=$arch" + if($beta) { + $releaseInfoUrl = $releaseInfoUrl + "&prerelease=true" + } + Write-Host "Finding latest release" + + $resp = Invoke-WebRequest -Uri "$releaseInfoUrl" -UseBasicParsing -Method GET + + $releaseInfo = @{} + foreach ($line in $resp.Content.Split("`n")) { + $info = $line -split "=" + $releaseInfo.add($info[0],$info[1]) + } + $url = $releaseInfo.url + } else { + $url = "https://github.com/buildkite/agent/releases/download/v$($version)/buildkite-agent-windows-$arch-$($version).zip" } - Write-Host "Finding latest release" - - $resp = Invoke-WebRequest -Uri "$releaseInfoUrl" -UseBasicParsing -Method GET - - $releaseInfo = @{} - foreach ($line in $resp.Content.Split("`n")) { - $info = $line -split "=" - $releaseInfo.add($info[0],$info[1]) - } - $url = $releaseInfo.url } # Github requires TLS1.2 From 9e14a4506cc48f31b9c930b8200186077e2f4aa6 Mon Sep 17 00:00:00 2001 From: Ellie <4158750+esenmarti@users.noreply.github.com> Date: Wed, 30 Oct 2024 11:18:20 +0100 Subject: [PATCH 2/3] Support version pinning in Linux (#3) --- install.sh | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/install.sh b/install.sh index a4a91d123c..d2d4a2929c 100755 --- a/install.sh +++ b/install.sh @@ -18,8 +18,6 @@ echo -e "\033[33m __/ | |___/\033[0m" -echo -e "Finding latest release..." - SYSTEM="$(uname -s | awk '{print tolower($0)}')" MACHINE="$(uname -m | awk '{print tolower($0)}')" @@ -73,11 +71,6 @@ else esac fi -RELEASE_INFO_URL="https://buildkite.com/agent/releases/latest?platform=${PLATFORM}&arch=${ARCH}&system=${SYSTEM}&machine=${MACHINE}" -if [[ "${BETA:-}" == "true" ]]; then - RELEASE_INFO_URL="${RELEASE_INFO_URL}&prerelease=true" -fi - if command -v curl >/dev/null 2>&1 ; then HTTP_GET="curl -LsS" elif command -v wget >/dev/null 2>&1 ; then @@ -88,11 +81,24 @@ else exit 1 fi -LATEST_RELEASE="$(eval "${HTTP_GET} '${RELEASE_INFO_URL}'")" +if [[ "${BUILDKITE_AGENT_VERSION:-"latest"}" == "latest" ]]; then + echo -e "Finding latest release..." + + RELEASE_INFO_URL="https://buildkite.com/agent/releases/latest?platform=${PLATFORM}&arch=${ARCH}&system=${SYSTEM}&machine=${MACHINE}" + if [[ "${BETA:-}" == "true" ]]; then + RELEASE_INFO_URL="${RELEASE_INFO_URL}&prerelease=true" + fi + + LATEST_RELEASE="$(eval "${HTTP_GET} '${RELEASE_INFO_URL}'")" -VERSION="$( echo "${LATEST_RELEASE}" | awk -F= '/version=/ { print $2 }')" -DOWNLOAD_FILENAME="$(echo "${LATEST_RELEASE}" | awk -F= '/filename=/ { print $2 }')" -DOWNLOAD_URL="$( echo "${LATEST_RELEASE}" | awk -F= '/url=/ { print $2 }')" + VERSION="$( echo "${LATEST_RELEASE}" | awk -F= '/version=/ { print $2 }')" + DOWNLOAD_FILENAME="$(echo "${LATEST_RELEASE}" | awk -F= '/filename=/ { print $2 }')" + DOWNLOAD_URL="$( echo "${LATEST_RELEASE}" | awk -F= '/url=/ { print $2 }')" +else + VERSION=$BUILDKITE_AGENT_VERSION + DOWNLOAD_FILENAME="buildkite-agent-${PLATFORM}-${ARCH}-${VERSION}.tar.gz" + DOWNLOAD_URL="https://github.com/buildkite/agent/releases/download/v${VERSION}/${DOWNLOAD_FILENAME}" +fi if [[ "${DISABLE_CHECKSUM_VERIFICATION:-}" != "true" ]]; then if command -v openssl >/dev/null 2>&1 ; then From 6fb90aebb817c44effd9b58a39a7fac6366c858c Mon Sep 17 00:00:00 2001 From: Jordan Carter Date: Thu, 7 Nov 2024 09:05:36 +1300 Subject: [PATCH 3/3] Add and remove quotes in bash substitution Co-authored-by: Josh Deprez --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index d2d4a2929c..de9467bc48 100755 --- a/install.sh +++ b/install.sh @@ -81,7 +81,7 @@ else exit 1 fi -if [[ "${BUILDKITE_AGENT_VERSION:-"latest"}" == "latest" ]]; then +if [[ "${BUILDKITE_AGENT_VERSION:-latest}" == "latest" ]]; then echo -e "Finding latest release..." RELEASE_INFO_URL="https://buildkite.com/agent/releases/latest?platform=${PLATFORM}&arch=${ARCH}&system=${SYSTEM}&machine=${MACHINE}" @@ -95,7 +95,7 @@ if [[ "${BUILDKITE_AGENT_VERSION:-"latest"}" == "latest" ]]; then DOWNLOAD_FILENAME="$(echo "${LATEST_RELEASE}" | awk -F= '/filename=/ { print $2 }')" DOWNLOAD_URL="$( echo "${LATEST_RELEASE}" | awk -F= '/url=/ { print $2 }')" else - VERSION=$BUILDKITE_AGENT_VERSION + VERSION="${BUILDKITE_AGENT_VERSION}" DOWNLOAD_FILENAME="buildkite-agent-${PLATFORM}-${ARCH}-${VERSION}.tar.gz" DOWNLOAD_URL="https://github.com/buildkite/agent/releases/download/v${VERSION}/${DOWNLOAD_FILENAME}" fi