forked from JetBrains/teamcity-docker-images
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathYaakAgentSetup.ps1
55 lines (41 loc) · 1.32 KB
/
YaakAgentSetup.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
param (
[string]$YaakServerUrl = "https://yaak.teamcity.com",
[string]$AgentBasePath = "C:/Agents",
[Parameter(Mandatory=$true)][string]$AgentName,
[string]$AgentAuthToken = $(Read-Host 'Enter one time use auth token or leave empty if agent was previously registered'),
[string]$DerivedDataCachePath = "C:\ddc"
)
docker login
$AgentFolder = Join-Path "${AgentBasePath}" -ChildPath "${AgentName}"
Write-Output "Creating build agent ${AgentFolder}"
$PreviousContainer = docker ps -a -q --filter="name=${AgentName}"
if ($PreviousContainer) {
Write-Output "cleaning up previous container"
docker stop ${PreviousContainer}
docker rm ${PreviousContainer}
}
Write-Output "Generating build agent file structure"
md -Force "${AgentFolder}/conf"
md -Force "${AgentFolder}/system"
md -Force "${AgentFolder}/work"
md -Force "$DerivedDataCachePath"
$params = @(
"--name=${AgentName}"
"-e"
"SERVER_URL=$YaakServerUrl"
"-e"
"AGENT_NAME=${AgentName}"
"-e"
"AGENT_TOKEN=${AgentAuthToken}"
"-v"
"${AgentFolder}/conf:C:/BuildAgent/conf"
"-v"
"${AgentFolder}/system:C:/BuildAgent/system"
"-v"
"${AgentFolder}/work:C:/BuildAgent/work"
"-v"
"${DerivedDataCachePath}:C:/ddc"
)
docker pull yaaktech/simcis:latest
docker run -d --restart always --isolation=process $params yaaktech/simcis:latest
Write-output "Agent setup successful!"