Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support installing specific versions via script #3069

Merged
merged 3 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
jordandcarter marked this conversation as resolved.
Show resolved Hide resolved
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
jordandcarter marked this conversation as resolved.
Show resolved Hide resolved
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