forked from appveyor/build-images
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start-build-container.ps1
66 lines (53 loc) · 1.19 KB
/
start-build-container.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
56
57
58
59
60
61
62
63
64
65
66
Param(
[Parameter(Mandatory=$true)]
[string]$token,
[Parameter(Mandatory=$true)]
[string]$branch,
[Parameter(Mandatory=$false)]
[string]$commitId,
[Parameter(Mandatory=$false)]
[string]$SKIP_TEMPLATE,
[Parameter(Mandatory=$false)]
[string]$SKIP_CLOUD
)
$headers = @{
"Authorization" = "Bearer $token"
"Content-type" = "application/json"
}
if ($commitId -eq "") {
$body = @{
accountName="AppVeyor"
projectSlug="build-container"
branch=$branch
}
}
else {
$body = @{
accountName="AppVeyor"
projectSlug="build-container"
branch=$branch
commitId=$commitId
}
}
$environmentVariables = ""
if ($SKIP_TEMPLATE -ne "") {
$environmentVariables = @{
SKIP_TEMPLATE=$SKIP_TEMPLATE
}
}
if ($SKIP_CLOUD -ne "") {
$environmentVariables = @{
SKIP_CLOUD=$SKIP_CLOUD
}
}
if ($SKIP_TEMPLATE -ne "" -and $SKIP_CLOUD -ne "") {
$environmentVariables = @{
SKIP_TEMPLATE=$SKIP_TEMPLATE
SKIP_CLOUD=$SKIP_CLOUD
}
}
if ($environmentVariables -ne "") {
$body.Add("environmentVariables", $environmentVariables)
}
$body = $body | ConvertTo-Json
Invoke-RestMethod -Uri 'https://ci.appveyor.com/api/builds' -Headers $headers -Body $body -Method PO