forked from OctopusDeploy/OctopusDSC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-virtualbox.ps1
executable file
·64 lines (50 loc) · 2.04 KB
/
build-virtualbox.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
#!/usr/local/bin/pwsh
param(
[switch]$offline
)
Start-Transcript .\vagrant-virtualbox.log
if($offline) # if you want to use offline, then you need a v3 and a v4 installer locally in the .\Tests folder (gitignored)
{
Write-Warning "Offline run requested, writing an offline.config file"
if(-not (Get-ChildItem .\Tests | Where-Object {$_.Name -like "Octopus.4.*.msi"}))
{
Write-Warning "To run tests offline, you will need a v4 installer in the .\Tests folder"
throw
}
if(-not (Get-ChildItem .\Tests | Where-Object {$_.Name -like "Octopus.3.*.msi"}))
{
Write-Warning "To run tests offline, you will need a v3 installer in the .\Tests folder"
throw
}
[pscustomobject]@{
v4file = (Get-ChildItem .\Tests | Where-Object {$_.Name -like "Octopus.3.*.msi"} | Select-Object -first 1 | Select-Object -expand Name);
v3file = (Get-ChildItem .\Tests | Where-Object {$_.Name -like "Octopus.4.*.msi"} | Select-Object -first 1 | Select-Object -expand Name);
} | ConvertTo-Json | Out-File ".\Tests\offline.config"
}
else {
# make sure the offline.config is not there
Remove-item ".\tests\offline.config" -verbose -ErrorAction SilentlyContinue
}
. Tests/powershell-helpers.ps1
if (-not (Test-AppExists "vagrant")) {
Write-Output "Please install vagrant from vagrantup.com."
exit 1
}
Write-Output "Vagrant installed - good."
if (-not (Test-AppExists "VBoxManage")) {
Write-Output "Please install VirtualBox from virtualbox.org."
exit 1
}
Write-Output "VirtualBox installed - good."
Test-PluginInstalled "vagrant-dsc"
Test-PluginInstalled "vagrant-winrm"
Test-PluginInstalled "vagrant-winrm-syncedfolders"
Write-Output "Running Pester Tests"
$result = Invoke-Pester -OutputFile PesterTestResults.xml -OutputFormat NUnitXml -PassThru
if ($result.FailedCount -gt 0) {
exit 1
}
Write-Output "Running 'vagrant up --provider virtualbox'"
vagrant up --provider virtualbox | Tee-Object -FilePath vagrant.log # --no-destroy-on-error --debug
Write-Output "Dont forget to run 'vagrant destroy -f' when you have finished"
stop-transcript