forked from sbates/omnibus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-omnibus.ps1
48 lines (41 loc) · 1.47 KB
/
build-omnibus.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
# can be called form SSH like so:
# powershell C:\omnibus\build-omnibus.ps1 'chef-client' 'opscode-full-stack' 'ACCESS_KEY' 'SECRET_KEY'
# legacy chef-full name should be chef-client
if ($args[0] -eq "chef-full") {
$project_name = "chef-client"
} else {
$project_name = $args[0]
}
$bucket_name = $args[1]
$s3_access_key = $args[2]
$s3_secret_key = $args[3]
$current_dir = (Split-Path ((Get-Variable MyInvocation -Scope 0).Value).MyCommand.Path) -replace "\\$", ""
Write-Output "Starting omnibus build of $project_name"
$json_attribs = @"
{
"aws": {
"access_key": "$s3_access_key",
"secret_access_key": "$s3_secret_key"
},
"omnibus": {
"$project_name": {
"version": "0.10.4",
"iteration": "6",
"bucket_name": "$bucket_name"
}
},
"run_list": [
"recipe[omnibus::default]"
]
}
"@
$json_attribs | Out-File -Encoding ASCII $current_dir\chef-repo\.chef\omnibus.json
# (FU) MS - we have to use a script block since Write-Host output doesn't go to STDERR or STDOUT
# https://connect.microsoft.com/PowerShell/feedback/details/283088/script-logging-needs-to-be-improved
$script = {
param([string] $solo_path)
Start-Process -FilePath 'git' 'pull' -WorkingDirectory "C:\omnibus" -Wait -NoNewWindow
Start-Process -FilePath 'chef-solo' "-c $solo_path\solo.rb -j $solo_path\omnibus.json" -Wait -NoNewWindow
}
PowerShell -Command $script -args "$current_dir\chef-repo\.chef" >> $ENV:TEMP\omnibus.out 2>&1
Write-Output "Finished build of $project_name"