Skip to content

Commit 734e2d9

Browse files
authored
Update Get-WorkItemsBetweenTwoBuilds.ps1
Formatting
1 parent 0f6b67f commit 734e2d9

File tree

1 file changed

+40
-31
lines changed

1 file changed

+40
-31
lines changed

scripts/Get-WorkItemsBetweenTwoBuilds.ps1

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,64 @@
11
<#
22
.SYNOPSIS
3-
Returns all linked work items between two builds
3+
Returns all linked work items between two builds
4+
45
.DESCRIPTION
5-
An Azure DevOps automation script that returns all linked work items between two builds
6+
An Azure DevOps automation script that returns all linked work items between two builds
7+
68
.PARAMETER PersonalAccessToken
7-
Azure DevOps personal access token (PAT) with the following scopes: Build (Read), Work Items (Read)
9+
Azure DevOps personal access token (PAT) with the following scopes: Build (Read), Work Items (Read)
10+
811
.PARAMETER OrganizationName
9-
Name of the Azure DevOps organization
12+
Name of the Azure DevOps organization
13+
1014
.PARAMETER ProjectName
11-
Name of the Azure DevOps project
15+
Name of the Azure DevOps project
16+
1217
.PARAMETER FromBuildId
13-
Id of the build to start searching
18+
Id of the build to start searching
19+
1420
.PARAMETER ToBuildId
15-
Id of the build to stop searching
21+
Id of the build to stop searching
22+
1623
.INPUTS
17-
None
24+
None
25+
1826
.OUTPUTS
19-
The linked work items between the two builds - printed to the console
27+
The linked work items between the two builds - printed to the console
28+
2029
.NOTES
21-
Version: 1.0
22-
Author: Marc Rufer
23-
Creation Date: 21.11.2023
24-
Purpose/Change: Initial script development
25-
30+
Version: 1.0
31+
Author: Marc Rufer
32+
Creation Date: 21.11.2023
33+
Purpose/Change: Initial script development
34+
2635
.EXAMPLE
27-
<Example goes here. Repeat this attribute for more than one example>
36+
PS> .\Get-WorkItemsBetweenTwoBuilds.ps1 -PersonalAccessToken "PAT_HERE" -OrganizationName "ORGANIZATION_NAME_HERE" -ProjectName "PROJECT_NAME_HERE" -FromBuildId "START_BUILD_ID_HERE" -ToBuildId "END_BUILD_ID_HERE"
2837
#>
2938
PARAM
3039
(
31-
[Parameter(Mandatory = $true, Position = 0, HelpMessage="Azure DevOps personal access token (PAT) with scopes: Build (Read), Work Items (Read).")]
32-
[string] $PersonalAccessToken
33-
,
34-
[Parameter(Mandatory = $true, Position = 1)]
35-
[string] $OrganizationName
36-
,
37-
[Parameter(Mandatory = $true, Position = 2)]
38-
[string] $ProjectName
39-
,
40-
[Parameter(Mandatory = $true, Position = 3)]
41-
[string] $FromBuildId
42-
,
43-
[Parameter(Mandatory = $true, Position = 4)]
44-
[string] $ToBuildId
40+
[Parameter(Mandatory = $true, Position = 0, HelpMessage="Azure DevOps personal access token (PAT) with scopes: Build (Read), Work Items (Read).")]
41+
[string] $PersonalAccessToken
42+
,
43+
[Parameter(Mandatory = $true, Position = 1)]
44+
[string] $OrganizationName
45+
,
46+
[Parameter(Mandatory = $true, Position = 2)]
47+
[string] $ProjectName
48+
,
49+
[Parameter(Mandatory = $true, Position = 3)]
50+
[string] $FromBuildId
51+
,
52+
[Parameter(Mandatory = $true, Position = 4)]
53+
[string] $ToBuildId
4554
)
4655

4756
$base64encodedPAT = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("`:$PersonalAccessToken"))
4857

4958
$uri = "https://dev.azure.com/{0}/{1}/_apis/build/workitems?fromBuildId={2}&toBuildId={3}&api-version=7.0" -f $OrganizationName, $ProjectName, $FromBuildId, $ToBuildId
5059
$response = Invoke-RestMethod -Method Get -Uri $uri -Headers @{'Authorization' = "Basic $base64encodedPAT" }
51-
52-
ForEach ($wi in $response.value) {
60+
61+
foreach ($wi in $response.value) {
5362
$uri = "https://dev.azure.com/{0}/{1}/_apis/wit/workItems/{2}?api-version=7.1-preview.3" -f $OrganizationName, $ProjectName, $wi.id
5463
$workItem = Invoke-RestMethod -Method Get -Uri $uri -Headers @{'Authorization' = "Basic $base64encodedPAT" }
5564

0 commit comments

Comments
 (0)