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 diff --git a/install.sh b/install.sh index a4a91d123c..de9467bc48 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