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

Enable overriding buildkite-agent url in install.ps1 #1805

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Changes from all 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
29 changes: 16 additions & 13 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ $installDir = "C:\buildkite-agent"
$beta = $env:buildkiteAgentBeta
$token = $env:buildkiteAgentToken
$tags = $env:buildkiteAgentTags
$url = $env:buildkiteAgentUrl

if ($(Get-ComputerInfo -Property OsArchitecture).OsArchitecture -eq "ARM 64-bit Processor") {
$arch = "arm64"
Expand Down Expand Up @@ -34,26 +35,28 @@ if($elevated -eq $false) {
throw "In order to install services, please run this script elevated."
}

$releaseInfoUrl = "https://buildkite.com/agent/releases/latest?platform=windows&arch=$arch"
if($beta) {
$releaseInfoUrl = $releaseInfoUrl + "&prerelease=true"
}

Write-Host "Finding latest release"
if ([string]::IsNullOrEmpty($url)) {
$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
$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])
$releaseInfo = @{}
foreach ($line in $resp.Content.Split("`n")) {
$info = $line -split "="
$releaseInfo.add($info[0],$info[1])
}
$url = $releaseInfo.url
}

# Github requires TLS1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

Write-Host "Downloading $($releaseInfo.url)"
Invoke-WebRequest -Uri $releaseInfo.url -OutFile 'buildkite-agent.zip'
Write-Host "Downloading $url"
Invoke-WebRequest -Uri $url -OutFile 'buildkite-agent.zip'

if (Test-Path -Path $installDir) {
$permissions = (Get-Acl $installDir).Access |
Expand Down