Functions/Get-AzDOYAMLPipelineStages.ps1
|
Function Get-AzDOYAMLPipelineStages { <# .SYNOPSIS Retrieves the stages of a specified Azure DevOps YAML pipeline. .DESCRIPTION This function queries the Azure DevOps API to get the YAML content of a pipeline and extracts the stages. .EXAMPLE Get-AzDOYAMLPipelineStages -Project "Alpha Devs" -PipelineID 12 .PARAMETER Project The name of your Azure DevOps project. .PARAMETER PipelineID The ID of your pipeline. .INPUTS Input is from command line or called from a script. .OUTPUTS Returns the stages extracted from the YAML pipeline definition. .NOTES Author: Lars Panzerbjørn Creation Date: 2024.07.25 #> [CmdletBinding(PositionalBinding=$False)] param( [Parameter()] [string]$Project = $Script:Project, [Parameter(Mandatory)] [string]$PipelineId ) BEGIN { Write-Verbose "Beginning $($MyInvocation.Mycommand)" $Uri = $BaseUri + "$Project/_apis/pipelines/$PipelineId/definitions?api-version=7.0" } PROCESS { Write-Verbose "Processing $($MyInvocation.Mycommand)" $PipelineDefinition = Invoke-RestMethod -Uri $Uri -Method GET -Headers $Header -ContentType $JsonContentType # Extract the YAML content from the pipeline definition $YamlContent = $PipelineDefinition.configuration.repository.yamlFileContent } END { Write-Verbose "Ending $($MyInvocation.Mycommand)" # Return the YAML content for further processing $YamlContent } } |