forked from StartAutomating/PSDevOps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Set-ADOBuild.ps1
77 lines (69 loc) · 2.19 KB
/
Set-ADOBuild.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
65
66
67
68
69
70
71
72
73
74
75
76
77
function Set-ADOBuild
{
<#
.Synopsis
Sets ADO Build information
.Description
Sets the Azure DevOps Build information
.Example
Set-ADOBuild -Log .\MyLog.log
.Example
Set-ADOBuild -BuildNumber 21
.Example
Set-ADOBuild -Tag TestPassed, CodeCoveragePassed
.Example
Set-ADOBuild -ReleaseName NewRelease
.Link
https://docs.microsoft.com/en-us/azure/devops/pipelines/scripts/logging-commands
#>
[CmdletBinding(PositionalBinding=$false)]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingWriteHost", "", Justification="Directly outputs in certain scenarios")]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "", Justification="Confirmation would be impossible within host")]
[OutputType([string])]
param(
# A new build number (or identifier)
[Parameter(ValueFromPipelineByPropertyName)]
[Alias('BN')]
[string]
$BuildNumber,
# One or more tags for this build
[Parameter(ValueFromPipelineByPropertyName)]
[Alias('T')]
[string[]]
$Tag,
# The name of the release
[Parameter(ValueFromPipelineByPropertyName)]
[Alias('Name','RN')]
[string]
$ReleaseName,
# Adds a location to the environment path
[Alias('PP','EP', 'PrependPath')]
[string]
$EnvironmentPath
)
process {
#region Prepare Output
$out = @(
if ($BuildNumber) {
"##vso[build.updatebuildnumber]$BuildNumber"
}
if ($tag) {
foreach ($t in $tag) {
"##vso[build.addbuildtag]$t"
}
}
if ($ReleaseName) {
"##vso[build.updatereleasename]$ReleaseName"
}
if ($EnvironmentPath) {
"##vso[task.prependpath]$EnvironmentPath"
}
)
#endregion Prepare Output
if ($env:Agent_ID -and $DebugPreference -eq 'SilentlyContinue') {
$out | Out-Host
} else {
$out -join [Environment]::NewLine
}
}
}