Skip to content

Commit 325c22f

Browse files
Get-ADOBuild: Attaching .BuildID and .DefinitionID to outputted results when provided
1 parent ee77c7b commit 325c22f

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

Get-ADOBuild.ps1

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@
269269
$definitionID = $psBoundParameters['DefinitionID'] = $in.DefinitionID
270270
}
271271
}
272+
if (($ParameterSet -like '*{BuildId}*') -and
273+
-not $BuildID -and
274+
($in.BuildID -ne $null)) {
275+
$buildID = $psBoundParameters['BuildID'] = $in.BuildID
276+
}
272277

273278
$q.Enqueue(@{ParameterSet=$ParameterSet} + $PSBoundParameters)
274279
}
@@ -331,6 +336,7 @@
331336
)"
332337

333338
$subtypename = @($parameterSet -replace '/{\w+}', '' -split '/')[-1].TrimEnd('s')
339+
334340
$subtypeName =
335341
if ($subtypename -eq 'Build') {
336342
''
@@ -349,18 +355,27 @@
349355
"$Organization.$project.Repository", "$Organization.Repository", "PSDevOps.Repository"
350356
}
351357

358+
$invokeParams.Property = @{
359+
Organization = $Organization
360+
Project = $Project
361+
Server = $Server
362+
}
363+
364+
if ($BuildID) {
365+
$invokeParams.Property.BuildID = $BuildID
366+
}
367+
368+
if ($DefinitionID) {
369+
$invokeParams.Property.DefinitionID = $DefinitionID
370+
}
352371

353372
if ($Detail)
354373
{
355374

356375
$null = $DequedInput.Remove('Detail')
357376
$null = $DequedInput.Remove('ParameterSet')
358377
$null = $DequedInput.Remove('AsJob')
359-
Invoke-ADORestAPI @invokeParams -Property @{
360-
Organization = $Organization
361-
Project = $Project
362-
Server = $Server
363-
} |
378+
Invoke-ADORestAPI @invokeParams |
364379
Add-Member NoteProperty ChangeSet -Value (Get-ADOBuild @DequedInput -ChangeSet) -Force -PassThru |
365380
Add-Member NoteProperty Timeline -Value (Get-ADOBuild @DequedInput -Timeline) -Force -PassThru |
366381
Add-Member NoteProperty Artifacts -Value (Get-ADOBuild @DequedInput -Artifact) -Force -PassThru |
@@ -392,11 +407,7 @@
392407
}
393408
else
394409
{
395-
Invoke-ADORestAPI @invokeParams -Property @{
396-
Organization = $Organization
397-
Project = $Project
398-
Server = $Server
399-
}
410+
Invoke-ADORestAPI @invokeParams
400411
}
401412
}
402413
if ($t -gt 1) {

0 commit comments

Comments
 (0)