Skip to content

A PowerShell script for automatic validation of the complete YAML source of an Azure Devops pipeline.

Notifications You must be signed in to change notification settings

ckadluba/ValidateYamlPipeline

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

ValidateYamlPipeline

A PowerShell script to validate the YAML files of an Azure DevOps pipeline.

The script can be used to validate a whole hierarchy of pipeline YAML. It can be used on a local git working tree of an Azure DevOps repo which contains the YAML source of an existing pipeline.

To achieve this the script automates the following actions.

  1. Save your local changes (git stash).
  2. Create a temporary branch and check it out.
  3. Commit your stashed changes to the temporary branch.
  4. Push the temporary branch to the origin.
  5. Call the Azure DevOps API to validate the pipeline with the given pipeline ID and the temporary branch
  6. Display the validation result.
  7. Switch back to your original branch.
  8. Restore your local changes (index and working tree from git stash).
  9. Delete the temporary branch.

Setup and Usage

  1. In Azure DevOps UI create a PAT token in Azure DevOps that has the permission to execute and read your existing pipeline in your project.
    image image
  2. Create the environment variable ValidateYamlPipeline_PAT containing the PAT token. image
  3. Get the organisation, project name and pipeline ID from the Azure DevOps UI.
  4. Make YAML changes in your local git working tree.
  5. Run the script to validate your changes.
    .\Validate-YamlPipeline.ps1 -OrgName "myorganisation" -ProjectName "MyProject" -PipelineId "2342"
    image

Steps 1 to 3 only have to be done once while 4 and 5 would normally occur repeatedly during YAML pipeline development.

Prerequisites

  • PowerShell 7
  • Azure DevOps account
  • Azure DevOps git repo with YAML pipeline source
  • Azure DevOps pipeline with ID
  • Azure DevOps PAT token

About

A PowerShell script for automatic validation of the complete YAML source of an Azure Devops pipeline.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published