Last active
December 17, 2020 22:08
-
-
Save manualbashing/5dc123e38b3b0ea02e3fec211b50ab1a to your computer and use it in GitHub Desktop.
PostInstall script for build agent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory)] | |
[string] | |
$AzureDevopsUrl, | |
[Parameter(Mandatory)] | |
[string] | |
$AzureDevopsPat, | |
[Parameter(Mandatory)] | |
[string] | |
$AgentPoolName | |
) | |
# Install PowerShell 7.1 | |
Invoke-WebRequest -Uri "https://github.com/PowerShell/PowerShell/releases/download/v7.1.0/PowerShell-7.1.0-win-x64.msi" -OutFile .\pwsh.msi | |
Start-Process msiexec.exe -Wait -ArgumentList '/I pwsh.msi /quiet ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL=0 ENABLE_PSREMOTING=0 REGISTER_MANIFEST=0' | |
rm .\pwsh.msi | |
# Install az cli | |
Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi | |
Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet' | |
rm .\AzureCLI.msi | |
# Install azure devops agent | |
mkdir C:\agent | |
Set-Location C:\agent | |
Invoke-WebRequest -Uri "https://vstsagentpackage.azureedge.net/agent/2.179.0/vsts-agent-win-x64-2.179.0.zip" -OutFile .\agent.zip | |
Add-Type -AssemblyName System.IO.Compression.FileSystem | |
[System.IO.Compression.ZipFile]::ExtractToDirectory("C:\agent\agent.zip", "C:\agent") | |
rm agent.zip | |
.\config.cmd --unattended --url $AzureDevopsUrl --auth pat --token $AzureDevopsPat --pool $AgentPoolName --runAsService |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment