-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for Pending Pipeline Approvals
- Loading branch information
1 parent
97e1bd6
commit ce7cb94
Showing
10 changed files
with
1,167 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,219 @@ | ||
function Get-APBuildTimeline | ||
{ | ||
<# | ||
.SYNOPSIS | ||
Returns Azure Pipeline build timeline. | ||
.DESCRIPTION | ||
Returns Azure Pipeline build timeline by build and timeline id. | ||
The build id can be retrieved by using Get-APBuildList. | ||
The timeline id can be retrieved by using Get-APBuildList under orchestrationPlan.planId. | ||
.PARAMETER Instance | ||
The Team Services account or TFS server. | ||
.PARAMETER Collection | ||
For Azure DevOps the value for collection should be the name of your orginization. | ||
For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. | ||
.PARAMETER Project | ||
Project ID or project name. | ||
.PARAMETER ApiVersion | ||
Version of the api to use. | ||
.PARAMETER PersonalAccessToken | ||
Personal access token used to authenticate that has been converted to a secure string. | ||
It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. | ||
https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts | ||
.PARAMETER Credential | ||
Specifies a user account that has permission to send the request. | ||
.PARAMETER Proxy | ||
Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. | ||
.PARAMETER ProxyCredential | ||
Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. | ||
.PARAMETER Session | ||
Azure DevOps PS session, created by New-APSession. | ||
.PARAMETER BuildId | ||
The id of the build. | ||
.PARAMETER TimelineId | ||
The id of the timeline. | ||
.PARAMETER ChangeId | ||
Undocumented. | ||
.PARAMETER PlanId | ||
Undocumented. | ||
.INPUTS | ||
None, does not support pipeline. | ||
.OUTPUTS | ||
PSObject, Azure Pipelines build(s). | ||
.EXAMPLE | ||
Returns the build timeline with the id of '7' for the 'myFirstProject. | ||
Get-APBuildTimeline -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -BuildId 7 -TimelineId xxxxx-xxxxx-xxxx-xxxxx | ||
.LINK | ||
https://docs.microsoft.com/en-us/rest/api/azure/devops/build/timeline/get?view=azure-devops-rest-6.0 | ||
#> | ||
[CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] | ||
Param | ||
( | ||
[Parameter(Mandatory, | ||
ParameterSetName = 'ByPersonalAccessToken')] | ||
[Parameter(Mandatory, | ||
ParameterSetName = 'ByCredential')] | ||
[uri] | ||
$Instance, | ||
|
||
[Parameter(Mandatory, | ||
ParameterSetName = 'ByPersonalAccessToken')] | ||
[Parameter(Mandatory, | ||
ParameterSetName = 'ByCredential')] | ||
[string] | ||
$Collection, | ||
|
||
[Parameter(Mandatory, | ||
ParameterSetName = 'ByPersonalAccessToken')] | ||
[Parameter(Mandatory, | ||
ParameterSetName = 'ByCredential')] | ||
[string] | ||
$Project, | ||
|
||
[Parameter(Mandatory, | ||
ParameterSetName = 'ByPersonalAccessToken')] | ||
[Parameter(Mandatory, | ||
ParameterSetName = 'ByCredential')] | ||
[string] | ||
$ApiVersion, | ||
|
||
[Parameter(ParameterSetName = 'ByPersonalAccessToken')] | ||
[Security.SecureString] | ||
$PersonalAccessToken, | ||
|
||
[Parameter(ParameterSetName = 'ByCredential')] | ||
[pscredential] | ||
$Credential, | ||
|
||
[Parameter(ParameterSetName = 'ByPersonalAccessToken')] | ||
[Parameter(ParameterSetName = 'ByCredential')] | ||
[string] | ||
$Proxy, | ||
|
||
[Parameter(ParameterSetName = 'ByPersonalAccessToken')] | ||
[Parameter(ParameterSetName = 'ByCredential')] | ||
[pscredential] | ||
$ProxyCredential, | ||
|
||
[Parameter(Mandatory, | ||
ParameterSetName = 'BySession')] | ||
[object] | ||
$Session, | ||
|
||
[Parameter(Mandatory)] | ||
[int] | ||
$BuildId, | ||
|
||
[Parameter(Mandatory)] | ||
[string] | ||
$TimelineId, | ||
|
||
[Parameter()] | ||
[string] | ||
$ChangeId, | ||
|
||
[Parameter()] | ||
[string] | ||
$PlanId | ||
) | ||
|
||
begin | ||
{ | ||
If ($PSCmdlet.ParameterSetName -eq 'BySession') | ||
{ | ||
$currentSession = $Session | Get-APSession | ||
If ($currentSession) | ||
{ | ||
$Instance = $currentSession.Instance | ||
$Collection = $currentSession.Collection | ||
$Project = $currentSession.Project | ||
$PersonalAccessToken = $currentSession.PersonalAccessToken | ||
$Credential = $currentSession.Credential | ||
$Proxy = $currentSession.Proxy | ||
$ProxyCredential = $currentSession.ProxyCredential | ||
If ($currentSession.Version) | ||
{ | ||
$ApiVersion = (Get-APApiVersion -Version $currentSession.Version) | ||
} | ||
else | ||
{ | ||
$ApiVersion = $currentSession.ApiVersion | ||
} | ||
} | ||
} | ||
} | ||
|
||
process | ||
{ | ||
$apiEndpoint = (Get-APApiEndpoint -ApiType 'build-timelineId') -f $BuildId, $TimelineId | ||
$queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters | ||
$setAPUriSplat = @{ | ||
Collection = $Collection | ||
Instance = $Instance | ||
Project = $Project | ||
ApiVersion = $ApiVersion | ||
ApiEndpoint = $apiEndpoint | ||
Query = $queryParameters | ||
} | ||
[uri] $uri = Set-APUri @setAPUriSplat | ||
$invokeAPRestMethodSplat = @{ | ||
Method = 'GET' | ||
Uri = $uri | ||
Credential = $Credential | ||
PersonalAccessToken = $PersonalAccessToken | ||
Proxy = $Proxy | ||
ProxyCredential = $ProxyCredential | ||
} | ||
$results = Invoke-APRestMethod @invokeAPRestMethodSplat | ||
If ($results.value) | ||
{ | ||
return $results.value | ||
} | ||
else | ||
{ | ||
return $results | ||
} | ||
} | ||
|
||
end | ||
{ | ||
} | ||
} |
Oops, something went wrong.