Skip to content

Commit

Permalink
Support for Pending Pipeline Approvals
Browse files Browse the repository at this point in the history
  • Loading branch information
Dejulia489 committed Jan 12, 2022
1 parent 97e1bd6 commit ce7cb94
Show file tree
Hide file tree
Showing 10 changed files with 1,167 additions and 33 deletions.
59 changes: 31 additions & 28 deletions AzurePipelinesPS/AzurePipelinesPS.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: Dejulia489
#
# Generated on: 27.9.2021
# Generated on: 1/12/2022
#

@{
Expand Down Expand Up @@ -32,20 +32,20 @@ Copyright = '(c) 2018 Dejulia489. All rights reserved.'
# Description of the functionality provided by this module
Description = 'A PowerShell module that makes interfacing with Azure Pipelines a little easier'

# Minimum version of the PowerShell engine required by this module
# Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '5.0'

# Name of the PowerShell host required by this module
# Name of the Windows PowerShell host required by this module
# PowerShellHostName = ''

# Minimum version of the PowerShell host required by this module
# Minimum version of the Windows PowerShell host required by this module
# PowerShellHostVersion = ''

# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# DotNetFrameworkVersion = ''

# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# ClrVersion = ''
# CLRVersion = ''

# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''
Expand Down Expand Up @@ -78,32 +78,33 @@ FunctionsToExport = 'Add-APDeploymentGroup', 'Add-APField', 'Add-APGroupMembersh
'Get-APBoardList', 'Get-APBuild', 'Get-APBuildArtifactList',
'Get-APBuildDefinition', 'Get-APBuildDefinitionList',
'Get-APBuildLease', 'Get-APBuildLeaseList', 'Get-APBuildList',
'Get-APDashboard', 'Get-APDashboardList', 'Get-APDeletedRepository',
'Get-APDeploymentGroup', 'Get-APDeploymentGroupList',
'Get-APDeploymentList', 'Get-APDescriptor', 'Get-APEnvironment',
'Get-APEnvironmentList', 'Get-APFeed', 'Get-APFeedList', 'Get-APField',
'Get-APFieldList', 'Get-APGitCommitList', 'Get-APGitItem',
'Get-APGitPullRequestList', 'Get-APGitRefList', 'Get-APGroup',
'Get-APGroupEntitlementsList', 'Get-APGroupList',
'Get-APGroupMembership', 'Get-APGroupMembershipList',
'Get-APInstalledExtension', 'Get-APInstalledExtensionData',
'Get-APInstalledExtensionDocument',
'Get-APBuildTimeline', 'Get-APDashboard', 'Get-APDashboardList',
'Get-APDeletedRepository', 'Get-APDeploymentGroup',
'Get-APDeploymentGroupList', 'Get-APDeploymentList',
'Get-APDescriptor', 'Get-APEnvironment', 'Get-APEnvironmentList',
'Get-APFeed', 'Get-APFeedList', 'Get-APField', 'Get-APFieldList',
'Get-APGitCommitList', 'Get-APGitItem', 'Get-APGitPullRequestList',
'Get-APGitRefList', 'Get-APGroup', 'Get-APGroupEntitlementsList',
'Get-APGroupList', 'Get-APGroupMembership',
'Get-APGroupMembershipList', 'Get-APInstalledExtension',
'Get-APInstalledExtensionData', 'Get-APInstalledExtensionDocument',
'Get-APInstalledExtensionDocumentList',
'Get-APInstalledExtensionList', 'Get-APList', 'Get-APListList',
'Get-APNode', 'Get-APNodeList', 'Get-APNotificationSubscription',
'Get-APNotificationSubscriptionList',
'Get-APNotificationSubscriptionTemplateList', 'Get-APOperation',
'Get-APPackage', 'Get-APPackageList', 'Get-APPermissionReport',
'Get-APPermissionReportList', 'Get-APPersonalAccessTokenList',
'Get-APPipeline', 'Get-APPipelineList', 'Get-APPipelineLog',
'Get-APPipelineLogList', 'Get-APPipelineRun', 'Get-APPipelineRunList',
'Get-APPlan', 'Get-APPlanList', 'Get-APPolicyConfiguration',
'Get-APPolicyConfigurationList', 'Get-APPolicyEvaluation',
'Get-APPolicyEvaluationList', 'Get-APPolicyRevision',
'Get-APPolicyRevisionList', 'Get-APPolicyType',
'Get-APPolicyTypeList', 'Get-APPool', 'Get-APPoolList',
'Get-APProcessList', 'Get-APProject', 'Get-APProjectList',
'Get-APQuery', 'Get-APQueryList', 'Get-APQueue',
'Get-APPipeline', 'Get-APPipelineApproval',
'Get-APPipelineApprovalList', 'Get-APPipelineList',
'Get-APPipelineLog', 'Get-APPipelineLogList', 'Get-APPipelineRun',
'Get-APPipelineRunList', 'Get-APPlan', 'Get-APPlanList',
'Get-APPolicyConfiguration', 'Get-APPolicyConfigurationList',
'Get-APPolicyEvaluation', 'Get-APPolicyEvaluationList',
'Get-APPolicyRevision', 'Get-APPolicyRevisionList',
'Get-APPolicyType', 'Get-APPolicyTypeList', 'Get-APPool',
'Get-APPoolList', 'Get-APProcessList', 'Get-APProject',
'Get-APProjectList', 'Get-APQuery', 'Get-APQueryList', 'Get-APQueue',
'Get-APRecycleBinRepository', 'Get-APRelease',
'Get-APReleaseDefinition', 'Get-APReleaseDefinitionList',
'Get-APReleaseEnvironment', 'Get-APReleaseList',
Expand Down Expand Up @@ -152,11 +153,13 @@ FunctionsToExport = 'Add-APDeploymentGroup', 'Add-APField', 'Add-APGroupMembersh
'Save-APPermissionReport', 'Save-APSession',
'Set-APAccessControlEntries', 'Set-APBuildNumber',
'Set-APReleaseName', 'Set-APTaskResult', 'Set-APVariable',
'Test-APPipelineYaml', 'Update-APApproval', 'Update-APBuild',
'Update-APBuildDefinition', 'Update-APDeploymentGroup',
'Update-APField', 'Update-APInstalledExtension',
'Get-APPipelinePendingApprovalList', 'Test-APPipelineYaml',
'Update-APApproval', 'Update-APBuild', 'Update-APBuildDefinition',
'Update-APDeploymentGroup', 'Update-APField',
'Update-APInstalledExtension',
'Update-APInstalledExtensionDocument', 'Update-APList',
'Update-APNode', 'Update-APPolicyConfiguration', 'Update-APRelease',
'Update-APNode', 'Update-APPipelineApproval',
'Update-APPolicyConfiguration', 'Update-APRelease',
'Update-APReleaseDefinition', 'Update-APReleaseEnvironment',
'Update-APReleaseResource', 'Update-APReleaseSummary',
'Update-APServiceEndpoint',
Expand Down
12 changes: 12 additions & 0 deletions AzurePipelinesPS/Private/Get-APApiEndpoint.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ function Get-APApiEndpoint
{
return '_apis/build/builds/{0}'
}
'build-timeline'
{
return '_apis/build/builds/{0}/timeline'
}
'build-timelineId'
{
return '_apis/build/builds/{0}/timeline/{1}'
}
'build-definitions'
{
return '_apis/build/definitions'
Expand Down Expand Up @@ -303,6 +311,10 @@ function Get-APApiEndpoint
{
return '_apis/pipelines/approvals'
}
'pipelines-approvalId'
{
return '_apis/pipelines/approvals/{0}'
}
'pipelines-pipelineId'
{
return '_apis/pipelines/{0}'
Expand Down
2 changes: 1 addition & 1 deletion AzurePipelinesPS/Public/Get-APBuild.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ function Get-APBuild
Proxy = $Proxy
ProxyCredential = $ProxyCredential
}
$results = Invoke-APRestMethod @invokeAPRestMethodSplat
$results = Invoke-APRestMethod @invokeAPRestMethodSplat
If ($results.value)
{
return $results.value
Expand Down
219 changes: 219 additions & 0 deletions AzurePipelinesPS/Public/Get-APBuildTimeline.ps1
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
{
}
}
Loading

0 comments on commit ce7cb94

Please sign in to comment.