Skip to content

Commit a8ba573

Browse files
Merge pull request #116 from StartAutomating/Get-ADOBuild-Improvements
Get-ADOBuild improvements
2 parents ee77c7b + 3eee110 commit a8ba573

File tree

5 files changed

+82
-10
lines changed

5 files changed

+82
-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) {

PSDevOps.types.ps1xml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,62 @@
197197
</ScriptProperty>
198198
</Members>
199199
</Type>
200+
<Type>
201+
<Name>PSDevOps.Build.Artifact</Name>
202+
<Members>
203+
<ScriptMethod>
204+
<Name>Download</Name>
205+
<Script>
206+
if ($this.resource.downloadUrl) {
207+
Invoke-ADORestAPI -Uri $this.resource.downloadURL -AsByte
208+
}
209+
210+
</Script>
211+
</ScriptMethod>
212+
<ScriptProperty>
213+
<Name>ArtifactData</Name>
214+
<GetScriptBlock>
215+
$this.resource.data
216+
217+
</GetScriptBlock>
218+
</ScriptProperty>
219+
<ScriptProperty>
220+
<Name>ArtifactType</Name>
221+
<GetScriptBlock>
222+
$this.Resource.type
223+
224+
</GetScriptBlock>
225+
</ScriptProperty>
226+
</Members>
227+
</Type>
228+
<Type>
229+
<Name>Deserialized.PSDevOps.Build.Artifact</Name>
230+
<Members>
231+
<ScriptMethod>
232+
<Name>Download</Name>
233+
<Script>
234+
if ($this.resource.downloadUrl) {
235+
Invoke-ADORestAPI -Uri $this.resource.downloadURL -AsByte
236+
}
237+
238+
</Script>
239+
</ScriptMethod>
240+
<ScriptProperty>
241+
<Name>ArtifactData</Name>
242+
<GetScriptBlock>
243+
$this.resource.data
244+
245+
</GetScriptBlock>
246+
</ScriptProperty>
247+
<ScriptProperty>
248+
<Name>ArtifactType</Name>
249+
<GetScriptBlock>
250+
$this.Resource.type
251+
252+
</GetScriptBlock>
253+
</ScriptProperty>
254+
</Members>
255+
</Type>
200256
<Type>
201257
<Name>PSDevOps.Build.Definition</Name>
202258
<Members>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
if ($this.resource.downloadUrl) {
2+
Invoke-ADORestAPI -Uri $this.resource.downloadURL -AsByte
3+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$this.resource.data
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$this.Resource.type

0 commit comments

Comments
 (0)