This repository has been archived by the owner on Dec 1, 2020. It is now read-only.
forked from OctopusDeploy/OctopusDSC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-azure.ps1
executable file
·53 lines (42 loc) · 1.73 KB
/
build-azure.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
#!/usr/local/bin/powershell
. Tests/powershell-helpers.ps1
Test-EnvVar AZURE_VM_PASSWORD
Test-EnvVar AZURE_SUBSCRIPTION_ID
Test-EnvVar AZURE_TENANT_ID
Test-EnvVar AZURE_CLIENT_ID
Test-EnvVar AZURE_CLIENT_SECRET
if (-not (Test-AppExists "vagrant")) {
write-host "Please install vagrant from vagrantup.com."
exit 1
}
write-host "Vagrant installed - good."
if (-not (Test-AppExists "azure")) {
write-host "Azure CLI not found. Please install from https://docs.microsoft.com/en-us/azure/xplat-cli-install."
exit 1
}
write-host "Azure CLI installed - good."
Test-PluginInstalled "vagrant-dsc"
Test-PluginInstalled "vagrant-azure" "2.0.0.pre7"
Test-PluginInstalled "vagrant-winrm"
Test-PluginInstalled "vagrant-winrm-syncedfolders"
Import-Module PSScriptAnalyzer
$excludedRules = @('PSUseShouldProcessForStateChangingFunctions', 'PSAvoidUsingPlainTextForPassword', 'PSAvoidUsingUserNameAndPassWordParams', 'PSAvoidUsingConvertToSecureStringWithPlainText')
$results = Invoke-ScriptAnalyzer ./OctopusDSC/DSCResources -recurse -exclude $excludedRules
write-output $results
write-output "PSScriptAnalyzer found $($results.length) issues"
if ($results.length -gt 0) {
echo "Aborting as PSScriptAnalyzer found issues."
exit $results.length
}
echo "Running Pester Tests"
Invoke-Pester -OutputFile PesterTestResults.xml -OutputFormat NUnitXml -EnableExit
echo "Running 'vagrant up --provider azure'"
vagrant up --provider azure # --debug &> vagrant.log
echo "'vagrant up' exited with exit code $LASTEXITCODE"
if ($LASTEXITCODE -ne 0)
{
echo "Vagrant up failed with exit code $LASTEXITCODE"
echo "##teamcity[buildStatus text='{build.status.text}. Vagrant failed.']"
exit $LASTEXITCODE
}
echo "Dont forget to run 'cleanup-azure.ps1' when you have finished"