-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathvstsBuild.ps1
More file actions
90 lines (74 loc) · 3.17 KB
/
Copy pathvstsBuild.ps1
File metadata and controls
90 lines (74 loc) · 3.17 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
[cmdletbinding(DefaultParameterSetName = 'Build')]
param(
)
DynamicParam {
# Add a dynamic parameter '-Name' which specifies the name of the build to run
# Get the names of the builds.
$buildJsonPath = (Join-Path -path $PSScriptRoot -ChildPath 'build.json')
$build = Get-Content -Path $buildJsonPath | ConvertFrom-Json
$names = @($build.Windows.Name)
foreach ($name in $build.Linux.Name) {
$names += $name
}
# Create the parameter attributes
$ParameterAttr = New-Object "System.Management.Automation.ParameterAttribute"
$ValidateSetAttr = New-Object "System.Management.Automation.ValidateSetAttribute" -ArgumentList $names
$Attributes = New-Object "System.Collections.ObjectModel.Collection``1[System.Attribute]"
$Attributes.Add($ParameterAttr) > $null
$Attributes.Add($ValidateSetAttr) > $null
# Create the parameter
$Parameter = New-Object "System.Management.Automation.RuntimeDefinedParameter" -ArgumentList ("Name", [string], $Attributes)
$Dict = New-Object "System.Management.Automation.RuntimeDefinedParameterDictionary"
$Dict.Add("Name", $Parameter) > $null
return $Dict
}
begin {
$Name = $PSBoundParameters['Name']
}
end {
$psReleaseBranch = 'master'
$psReleaseFork = 'PowerShell'
$psReleaseLocation = Join-Path -Path $PSScriptRoot -ChildPath 'PSRelease'
if (Test-Path $psReleaseLocation) {
Remove-Item -Path $psReleaseLocation -Recurse -Force
}
$gitBinFullPath = (Get-Command -Name git).Source
if (-not $gitBinFullPath) {
throw "Git is required to proceed. Install from 'https://git-scm.com/download/win'"
}
Write-Verbose "cloning -b $psReleaseBranch --quiet https://github.com/$psReleaseFork/PSRelease.git" -verbose
& $gitBinFullPath clone -b $psReleaseBranch --quiet https://github.com/$psReleaseFork/PSRelease.git $psReleaseLocation
Push-Location -Path $PWD.Path
try {
Set-Location $psReleaseLocation
& $gitBinFullPath submodule update --init --recursive --quiet
}
finally {
Pop-Location
}
$unresolvedRepoRoot = Join-Path -Path $PSScriptRoot '../..'
$resolvedRepoRoot = (Resolve-Path -Path $unresolvedRepoRoot).ProviderPath
try {
Write-Verbose "Starting build at $resolvedRepoRoot ..." -Verbose
Import-Module "$psReleaseLocation/vstsBuild" -Force
Import-Module "$psReleaseLocation/dockerBasedBuild" -Force
Clear-VstsTaskState
Invoke-Build -RepoPath $resolvedRepoRoot -BuildJsonPath "tools/releaseBuild/build.json" -Name $Name
}
catch {
Write-VstsError -Error $_
}
finally {
$testResultPath = Get-ChildItem $env:AGENT_TEMPDIRECTORY -Recurse -Filter 'native-tests.xml'
if ($testResultPath -and (Test-Path $testResultPath)) {
Write-Host "##vso[results.publish type=JUnit;mergeResults=true;runTitle=Native Test Results;publishRunAttachments=true;resultFiles=$testResultPath;]"
}
else {
Write-Verbose -Verbose "Test results file was not found."
}
Write-VstsTaskState
exit 0
}
}