Skip to content

Commit

Permalink
Update Get-VSTeamRelease cmldet to get release via artifact ids (#374)
Browse files Browse the repository at this point in the history
* Added new parameter artifactVersionId to the function Get-VSTeamRelease

Co-authored-by: Donovan Brown <[email protected]>
Co-authored-by: Sebastian Schütze <[email protected]>
  • Loading branch information
3 people authored Jun 25, 2021
1 parent e6cd718 commit b7431d1
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .docs/Get-VSTeamRelease.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions Source/Public/Get-VSTeamRelease.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ function Get-VSTeamRelease {
[Parameter(ParameterSetName = 'List')]
[int] $definitionId,

[Parameter(ParameterSetName = 'List')]
[string] $artifactVersionId,

[Parameter(ParameterSetName = 'List')]
[int] $top,

Expand Down Expand Up @@ -94,6 +97,7 @@ function Get-VSTeamRelease {
'minCreatedTime' = $minCreatedTime
'maxCreatedTime' = $maxCreatedTime
'continuationToken' = $continuationToken
'artifactVersionId' = $artifactVersionId
}

# Call the REST API
Expand Down
12 changes: 12 additions & 0 deletions Tests/function/tests/Get-VSTeamRelease.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
}

0 comments on commit b7431d1

Please sign in to comment.