Skip to main content

Test-VSTeamYamlPipeline

SYNOPSIS

Validates the local YAML pipeline against Azure DevOps.

SYNTAX

WithFilePath (Default)

Test-VSTeamYamlPipeline [-PipelineId] <Int32> [-FilePath <String>] [-Branch <String>] -ProjectName <String>
[<CommonParameters>]

WithYamlOverride

Test-VSTeamYamlPipeline [-PipelineId] <Int32> [-YamlOverride <String>] [-Branch <String>] -ProjectName <String>
[<CommonParameters>]

DESCRIPTION

Validates the local YAML pipeline against Azure DevOps.

Now, you can try out a YAML pipeline without committing it to a repo or running it. Given an existing pipeline and an optional new YAML payload, this function will give you back the fully compiled YAML pipeline including templates.

EXAMPLES

Example 1

Test-VSTeamYamlPipeline -Project DemoProject -PipelineId 24 -FilePath './azure-pipelines.yml'

This example checks the YAML pipeline with ID 24 and the file './azure-pipelines.yml' for consistency on Azure DevOps to see if the changes still work.

Example 2

$yamlOverride = [string](Get-Content -raw $FilePath)
Test-VSTeamYamlPipeline -Project DemoProject -PipelineId 24 -YamlOverride $yamlOverride

This example checks the YAML pipeline with ID 24 and the content of a yaml file in the variable $yamlOverride for consistency on Azure DevOps to see if the changes still work.

Example 3

Test-VSTeamYamlPipeline -Project DemoProject -PipelineId 24 -Branch 'main'

This example checks the YAML in the remote repository connected to the pipeline with ID 24 for consistency on Azure DevOps. It will take the file for the branch 'main'.

Example 4

Test-VSTeamYamlPipeline -Project DemoProject -PipelineId 24 - Branch 'refs/heads/feature/test'

This example checks the YAML in the remote repository connected to the pipeline with ID 24 for consistency on Azure DevOps. It will take the file for the branch ref 'refs/heads/feature/test'.

Example 5

Test-VSTeamYamlPipeline -Project DemoProject -PipelineId 24

This example checks the YAML file pipeline with ID 24 for consistency on Azure DevOps to see if the existing YAML of the pipeline works.

PARAMETERS

-PipelineId

Id of the YAML pipeline to be checked

Type: Int32
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False

-FilePath

Path to the file that should be checked

Type: String
Parameter Sets: WithFilePath
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Branch

branch name of the remote repository where the YAML file should be checked

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-YamlOverride

YAML content that should be checked

Type: String
Parameter Sets: WithYamlOverride
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ProjectName

Specifies the team project for which this function operates.

You can tab complete from a list of available projects.

You can use Set-VSTeamDefaultProject to set a default project so you do not have to pass the ProjectName with each call.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

System.String

FilePath

System.Int32

PipelineId

OUTPUTS

vsteam_lib.YamlPipelineResult

NOTES

Currently the API that is used by this cmdlet is only supporting YAML pipelines without template references. This will be supported soon. see the issue in GitHub: https://github.com/microsoft/azure-pipelines-yaml/issues/34#issuecomment-591092498 (https://github.com/microsoft/azure-pipelines-yaml/issues/34#issuecomment-591092498)This cmdlet is not starting a pipeline run, but rather trying to resolve the full YAML code. It will not check if the task themselves work. See here for more info https://www.razorspoint.com/2020/03/13/how-to-preview-and-test-a-changing-yaml-pipeline-on-azure-devops/ (https://www.razorspoint.com/2020/03/13/how-to-preview-and-test-a-changing-yaml-pipeline-on-azure-devops/)Prerequisites:

Set the account and version that all calls will use with Set-VSTeamAccount. Default version sets to API version 3.0 (TFS2017) if not manually set.

tips:

  • check called version of the API with Get-VSTeamAPIVersion or Get-VSTeamInfo
  • use Set-VSTeamDefaultProject to set default project for every call
  • use Set-VSTeamDefaultAPITimeout to change the default timeout of 60 seconds for all calls.
  • use Profiles to load an account and the correct version

Get-VSTeamBuildDefinition