Skip to content

Commit

Permalink
Merge pull request #3069 from buildkite/install-support-version-pinning
Browse files Browse the repository at this point in the history
Support installing specific versions via script
  • Loading branch information
jordandcarter authored Nov 6, 2024
2 parents 80c8c46 + 6fb90ae commit 8938472
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 24 deletions.
30 changes: 17 additions & 13 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 17 additions & 11 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)}')"

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 8938472

Please sign in to comment.