forked from POSHChef/POSHChef
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
37 lines (28 loc) · 943 Bytes
/
build.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
# Build script for testing and packaging up POSHChef
#
# Author: Russell Seymour
# Company: Turtlesystems Consulting
param (
[string]
# Version to apply to the build
$version = [String]::Empty
)
# Determine paths to required utilities
$nuget = $env:Nuget
if ([String]::IsNullOrEmpty($nuget)) {
$nuget = "nuget"
}
# Get the version from the environment if it has not been set
if ([String]::IsNullOrEmpty($version)) {
$version = $env:PackageVersion
}
# Invoke-Pester from the current location and get the results back
$results = Invoke-Pester -Path . -Passthru
# If there are failed tests then abort the build
if ($results.FailedCount -gt 0) {
$message = "##myget[buildProblem description='Build failed, {0} tests failed']" -f $results.failedcount
Write-Output $message
} else {
# If there then the tests have passed so attempt to build the package
. $nuget pack POSHChef.nuspec -version $version -nopackageanalysis
}