Skip to content

Instantly share code, notes, and snippets.

@jlattimer
Last active January 22, 2019 17:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlattimer/691b1712d8721a288f082b0059873ebe to your computer and use it in GitHub Desktop.
Save jlattimer/691b1712d8721a288f082b0059873ebe to your computer and use it in GitHub Desktop.
Windows server Docker container suitable for D365 CE builds & tests from Azure DevOps (start.ps1) v1.0 #blog
# https://sigaostudios.com/azure-devops-build-and-release-agents-with-docker/
# D365 CE Build/Test Server v1.1
$ErrorActionPreference = "Stop"
$env:VSTS_ACCOUNT = "Azure DevOps instance name"
$env:VSTS_TOKEN = "Azure DevOps Personal Access Token"
$env:VSTS_POOL = ""
If ($env:VSTS_ACCOUNT -eq $null) {
Write-Error "Missing VSTS_ACCOUNT environment variable"
exit 1
}
if ($env:VSTS_TOKEN -eq $null) {
Write-Error "Missing VSTS_TOKEN environment variable"
exit 1
}
else {
if (Test-Path -Path $env:VSTS_TOKEN -PathType Leaf) {
$env:VSTS_TOKEN = Get-Content -Path $env:VSTS_TOKEN -ErrorAction Stop | Where-Object {$_} | Select-Object -First 1
if ([string]::IsNullOrEmpty($env:VSTS_TOKEN)) {
Write-Error "Missing VSTS_TOKEN file content"
exit 1
}
}
}
if ($env:VSTS_AGENT -ne $null) {
$env:VSTS_AGENT = $($env:VSTS_AGENT)
}
else {
$env:VSTS_AGENT = $env:COMPUTERNAME
}
if ($env:VSTS_WORK -ne $null) {
New-Item -Path $env:VSTS_WORK -ItemType Directory -Force
}
else {
$env:VSTS_WORK = "_work"
}
if ($env:VSTS_POOL -eq $null) {
$env:VSTS_POOL = "Default"
}
# Set The Configuration and Run The Agent
Set-Location -Path "C:\BuildAgent"
& .\bin\Agent.Listener.exe configure --unattended `
--agent "$env:VSTS_AGENT" `
--url "https://$env:VSTS_ACCOUNT.visualstudio.com" `
--auth PAT `
--token "$env:VSTS_TOKEN" `
--pool "$env:VSTS_POOL" `
--work "$env:VSTS_WORK" `
--replace
& .\bin\Agent.Listener.exe run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment