|
1 | 1 | <# |
2 | 2 | .SYNOPSIS |
3 | | - Returns all linked work items between two builds |
| 3 | +Returns all linked work items between two builds |
| 4 | +
|
4 | 5 | .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 | +
|
6 | 8 | .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 | +
|
8 | 11 | .PARAMETER OrganizationName |
9 | | - Name of the Azure DevOps organization |
| 12 | +Name of the Azure DevOps organization |
| 13 | +
|
10 | 14 | .PARAMETER ProjectName |
11 | | - Name of the Azure DevOps project |
| 15 | +Name of the Azure DevOps project |
| 16 | +
|
12 | 17 | .PARAMETER FromBuildId |
13 | | - Id of the build to start searching |
| 18 | +Id of the build to start searching |
| 19 | +
|
14 | 20 | .PARAMETER ToBuildId |
15 | | - Id of the build to stop searching |
| 21 | +Id of the build to stop searching |
| 22 | +
|
16 | 23 | .INPUTS |
17 | | - None |
| 24 | +None |
| 25 | +
|
18 | 26 | .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 | +
|
20 | 29 | .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 | +
|
26 | 35 | .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" |
28 | 37 | #> |
29 | 38 | PARAM |
30 | 39 | ( |
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 |
45 | 54 | ) |
46 | 55 |
|
47 | 56 | $base64encodedPAT = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("`:$PersonalAccessToken")) |
48 | 57 |
|
49 | 58 | $uri = "https://dev.azure.com/{0}/{1}/_apis/build/workitems?fromBuildId={2}&toBuildId={3}&api-version=7.0" -f $OrganizationName, $ProjectName, $FromBuildId, $ToBuildId |
50 | 59 | $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) { |
53 | 62 | $uri = "https://dev.azure.com/{0}/{1}/_apis/wit/workItems/{2}?api-version=7.1-preview.3" -f $OrganizationName, $ProjectName, $wi.id |
54 | 63 | $workItem = Invoke-RestMethod -Method Get -Uri $uri -Headers @{'Authorization' = "Basic $base64encodedPAT" } |
55 | 64 |
|
|
0 commit comments