From b7431d104b706a85646a5b1c3aaa0604bb5a695c Mon Sep 17 00:00:00 2001 From: Harish Karthic Date: Fri, 25 Jun 2021 10:06:41 +0100 Subject: [PATCH] Update Get-VSTeamRelease cmldet to get release via artifact ids (#374) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added new parameter artifactVersionId to the function Get-VSTeamRelease Co-authored-by: Donovan Brown Co-authored-by: Sebastian Schütze --- .docs/Get-VSTeamRelease.md | 17 +++++++++++++++++ CHANGELOG.md | 9 +++++++++ Source/Public/Get-VSTeamRelease.ps1 | 4 ++++ .../function/tests/Get-VSTeamRelease.Tests.ps1 | 12 ++++++++++++ 4 files changed, 42 insertions(+) diff --git a/.docs/Get-VSTeamRelease.md b/.docs/Get-VSTeamRelease.md index b09d6bed6..f8a768aeb 100644 --- a/.docs/Get-VSTeamRelease.md +++ b/.docs/Get-VSTeamRelease.md @@ -46,6 +46,14 @@ Get-VSTeamRelease -ProjectName demo -Id 10 -Json This command returns the raw object returned from the server formatted as JSON. +### Example 4 + +```powershell +Get-VSTeamRelease -ProjectName demo -artifactVersionId 7 +``` + +This command returns the associated release for given Id. If the artifact type is a "Build" (Azure Pipelines) then it is the id of the build. + ## PARAMETERS ### Expand @@ -76,6 +84,15 @@ Parameter Sets: List Default value: 0 ``` +### ArtifactVersionId + +Id of the artifact version. Returns the particular release pertaining to given artifact version Id. + +```yaml +Type: String +Parameter Sets: List +``` + ### Top Specifies the maximum number to return. diff --git a/CHANGELOG.md b/CHANGELOG.md index d3da10ace..51f321170 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,15 @@ Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/384) from [Se - Add-VSTeamPool, Remove-VSTeamPool and Update-VSTeampool for handling agent pools on Azure DevOps +Merged [Pull Request](https://github.com/MethodsAndPractices/vsteam/pull/374) from [hkarthik7](https://github.com/hkarthik7) which includes the following: + +- Added a new parameter artifactVersionId to Get-VSTeamRelease cmdlet. This will help to return the release for passed artifact Id. For instance the release details of a build can be retrieved by passing build Id to the cmdlet. + +```powershell +$buildId = Get-VSTeamBuild -Top 1 +Get-VSTeamRelease -artifactVersionId $buildId.Id +``` + ## 7.2.0 Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/371) and (https://github.com/DarqueWarrior/vsteam/pull/389) from [Sebastian Schütze](https://github.com/SebastianSchuetze) which included the following: diff --git a/Source/Public/Get-VSTeamRelease.ps1 b/Source/Public/Get-VSTeamRelease.ps1 index 26d15fdac..40b4c561c 100644 --- a/Source/Public/Get-VSTeamRelease.ps1 +++ b/Source/Public/Get-VSTeamRelease.ps1 @@ -20,6 +20,9 @@ function Get-VSTeamRelease { [Parameter(ParameterSetName = 'List')] [int] $definitionId, + [Parameter(ParameterSetName = 'List')] + [string] $artifactVersionId, + [Parameter(ParameterSetName = 'List')] [int] $top, @@ -94,6 +97,7 @@ function Get-VSTeamRelease { 'minCreatedTime' = $minCreatedTime 'maxCreatedTime' = $maxCreatedTime 'continuationToken' = $continuationToken + 'artifactVersionId' = $artifactVersionId } # Call the REST API diff --git a/Tests/function/tests/Get-VSTeamRelease.Tests.ps1 b/Tests/function/tests/Get-VSTeamRelease.Tests.ps1 index c025f6b5d..a84119ec5 100644 --- a/Tests/function/tests/Get-VSTeamRelease.Tests.ps1 +++ b/Tests/function/tests/Get-VSTeamRelease.Tests.ps1 @@ -79,5 +79,17 @@ Describe 'VSTeamRelease' { $Uri -eq "https://vsrm.dev.azure.com/test/_apis/release/releases?api-version=$(_getApiVersion Release)" } } + + It 'with build Id should return release as Object' { + ## Act + $r = Get-VSTeamRelease -ProjectName VSTeamRelease -artifactVersionId 101 + + ## Assert + $r | Get-Member | Select-Object -First 1 -ExpandProperty TypeName | Should -Be 'vsteam_lib.Release' + + Should -Invoke Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter { + $Uri -eq "https://vsrm.dev.azure.com/test/VSTeamRelease/_apis/release/releases?api-version=$(_getApiVersion Release)&artifactVersionId=101" + } + } } } \ No newline at end of file