BranchPolicyBuildValidation

Manages a build validation branch policy within Azure DevOps.

Example Usage

using Pulumi;
using AzureDevOps = Pulumi.AzureDevOps;

class MyStack : Stack
{
    public MyStack()
    {
        var project = new AzureDevOps.Core.Project("project", new AzureDevOps.Core.ProjectArgs
        {
            ProjectName = "Sample Project",
        });
        var git = new AzureDevOps.Repository.Git("git", new AzureDevOps.Repository.GitArgs
        {
            ProjectId = project.Id,
            Initialization = new AzureDevOps.Repository.Inputs.GitInitializationArgs
            {
                InitType = "Clean",
            },
        });
        var buildDefinition = new AzureDevOps.Build.BuildDefinition("buildDefinition", new AzureDevOps.Build.BuildDefinitionArgs
        {
            ProjectId = project.Id,
            Repository = new AzureDevOps.Build.Inputs.BuildDefinitionRepositoryArgs
            {
                RepoType = "TfsGit",
                RepoId = git.Id,
                YmlPath = "azure-pipelines.yml",
            },
        });
        var branchPolicyBuildValidation = new AzureDevOps.Policy.BranchPolicyBuildValidation("branchPolicyBuildValidation", new AzureDevOps.Policy.BranchPolicyBuildValidationArgs
        {
            ProjectId = project.Id,
            Enabled = true,
            Blocking = true,
            Settings = new AzureDevOps.Policy.Inputs.BranchPolicyBuildValidationSettingsArgs
            {
                DisplayName = "Don't break the build!",
                BuildDefinitionId = buildDefinition.Id,
                ValidDuration = 720,
                Scope = 
                {
                    
                    {
                        { "repositoryId", git.Id },
                        { "repositoryRef", git.DefaultBranch },
                        { "matchType", "Exact" },
                    },
                    
                    {
                        { "repositoryId", git.Id },
                        { "repositoryRef", "refs/heads/releases" },
                        { "matchType", "Prefix" },
                    },
                },
            },
        });
    }

}
package main

import (
    "github.com/pulumi/pulumi-azuredevops/sdk/go/azuredevops/Build"
    "github.com/pulumi/pulumi-azuredevops/sdk/go/azuredevops/Core"
    "github.com/pulumi/pulumi-azuredevops/sdk/go/azuredevops/Policy"
    "github.com/pulumi/pulumi-azuredevops/sdk/go/azuredevops/Repository"
    "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        project, err := Core.NewProject(ctx, "project", &Core.ProjectArgs{
            ProjectName: pulumi.String("Sample Project"),
        })
        if err != nil {
            return err
        }
        git, err := Repository.NewGit(ctx, "git", &Repository.GitArgs{
            ProjectId: project.ID(),
            Initialization: &Repository.GitInitializationArgs{
                InitType: pulumi.String("Clean"),
            },
        })
        if err != nil {
            return err
        }
        buildDefinition, err := Build.NewBuildDefinition(ctx, "buildDefinition", &Build.BuildDefinitionArgs{
            ProjectId: project.ID(),
            Repository: &Build.BuildDefinitionRepositoryArgs{
                RepoType: pulumi.String("TfsGit"),
                RepoId:   git.ID(),
                YmlPath:  pulumi.String("azure-pipelines.yml"),
            },
        })
        if err != nil {
            return err
        }
        branchPolicyBuildValidation, err := Policy.NewBranchPolicyBuildValidation(ctx, "branchPolicyBuildValidation", &Policy.BranchPolicyBuildValidationArgs{
            ProjectId: project.ID(),
            Enabled:   pulumi.Bool(true),
            Blocking:  pulumi.Bool(true),
            Settings: &Policy.BranchPolicyBuildValidationSettingsArgs{
                DisplayName:       pulumi.String("Don't break the build!"),
                BuildDefinitionId: pulumi.Int(buildDefinition.ID()),
                ValidDuration:     pulumi.Int(720),
                Scope: []interface{}{
                    map[string]interface{}{
                        "repositoryId":  git.ID(),
                        "repositoryRef": git.DefaultBranch,
                        "matchType":     "Exact",
                    },
                    map[string]interface{}{
                        "repositoryId":  git.ID(),
                        "repositoryRef": "refs/heads/releases",
                        "matchType":     "Prefix",
                    },
                },
            },
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_azuredevops as azuredevops

project = azuredevops.core.Project("project", project_name="Sample Project")
git = azuredevops.repository.Git("git",
    project_id=project.id,
    initialization={
        "initType": "Clean",
    })
build_definition = azuredevops.build.BuildDefinition("buildDefinition",
    project_id=project.id,
    repository={
        "repoType": "TfsGit",
        "repoId": git.id,
        "ymlPath": "azure-pipelines.yml",
    })
branch_policy_build_validation = azuredevops.policy.BranchPolicyBuildValidation("branchPolicyBuildValidation",
    project_id=project.id,
    enabled=True,
    blocking=True,
    settings={
        "display_name": "Don't break the build!",
        "buildDefinitionId": build_definition.id,
        "validDuration": 720,
        "scope": [
            {
                "repositoryId": git.id,
                "repositoryRef": git.default_branch,
                "matchType": "Exact",
            },
            {
                "repositoryId": git.id,
                "repositoryRef": "refs/heads/releases",
                "matchType": "Prefix",
            },
        ],
    })
import * as pulumi from "@pulumi/pulumi";
import * as azuredevops from "@pulumi/azuredevops";

const project = new azuredevops.Core.Project("project", {projectName: "Sample Project"});
const git = new azuredevops.Repository.Git("git", {
    projectId: project.id,
    initialization: {
        initType: "Clean",
    },
});
const buildDefinition = new azuredevops.Build.BuildDefinition("buildDefinition", {
    projectId: project.id,
    repository: {
        repoType: "TfsGit",
        repoId: git.id,
        ymlPath: "azure-pipelines.yml",
    },
});
const branchPolicyBuildValidation = new azuredevops.Policy.BranchPolicyBuildValidation("branchPolicyBuildValidation", {
    projectId: project.id,
    enabled: true,
    blocking: true,
    settings: {
        displayName: "Don't break the build!",
        buildDefinitionId: buildDefinition.id,
        validDuration: 720,
        scope: [
            {
                repositoryId: git.id,
                repositoryRef: git.defaultBranch,
                matchType: "Exact",
            },
            {
                repositoryId: git.id,
                repositoryRef: "refs/heads/releases",
                matchType: "Prefix",
            },
        ],
    },
});

Create a BranchPolicyBuildValidation Resource

def BranchPolicyBuildValidation(resource_name, opts=None, blocking=None, enabled=None, project_id=None, settings=None, __props__=None);
name string
The unique name of the resource.
args BranchPolicyBuildValidationArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
opts ResourceOptions
A bag of options that control this resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args BranchPolicyBuildValidationArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args BranchPolicyBuildValidationArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

BranchPolicyBuildValidation Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.

Inputs

The BranchPolicyBuildValidation resource accepts the following input properties:

ProjectId string

The ID of the project in which the policy will be created.

Settings Pulumi.AzureDevOps.Policy.Inputs.BranchPolicyBuildValidationSettingsArgs

Configuration for the policy. This block must be defined exactly once.

Blocking bool

A flag indicating if the policy should be blocking. Defaults to true.

Enabled bool

A flag indicating if the policy should be enabled. Defaults to true.

ProjectId string

The ID of the project in which the policy will be created.

Settings BranchPolicyBuildValidationSettings

Configuration for the policy. This block must be defined exactly once.

Blocking bool

A flag indicating if the policy should be blocking. Defaults to true.

Enabled bool

A flag indicating if the policy should be enabled. Defaults to true.

projectId string

The ID of the project in which the policy will be created.

settings BranchPolicyBuildValidationSettings

Configuration for the policy. This block must be defined exactly once.

blocking boolean

A flag indicating if the policy should be blocking. Defaults to true.

enabled boolean

A flag indicating if the policy should be enabled. Defaults to true.

project_id str

The ID of the project in which the policy will be created.

settings Dict[BranchPolicyBuildValidationSettings]

Configuration for the policy. This block must be defined exactly once.

blocking bool

A flag indicating if the policy should be blocking. Defaults to true.

enabled bool

A flag indicating if the policy should be enabled. Defaults to true.

Outputs

All input properties are implicitly available as output properties. Additionally, the BranchPolicyBuildValidation resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.

Look up an Existing BranchPolicyBuildValidation Resource

Get an existing BranchPolicyBuildValidation resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

static get(resource_name, id, opts=None, blocking=None, enabled=None, project_id=None, settings=None, __props__=None);
func GetBranchPolicyBuildValidation(ctx *Context, name string, id IDInput, state *BranchPolicyBuildValidationState, opts ...ResourceOption) (*BranchPolicyBuildValidation, error)
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.

The following state arguments are supported:

Blocking bool

A flag indicating if the policy should be blocking. Defaults to true.

Enabled bool

A flag indicating if the policy should be enabled. Defaults to true.

ProjectId string

The ID of the project in which the policy will be created.

Settings Pulumi.AzureDevOps.Policy.Inputs.BranchPolicyBuildValidationSettingsArgs

Configuration for the policy. This block must be defined exactly once.

Blocking bool

A flag indicating if the policy should be blocking. Defaults to true.

Enabled bool

A flag indicating if the policy should be enabled. Defaults to true.

ProjectId string

The ID of the project in which the policy will be created.

Settings BranchPolicyBuildValidationSettings

Configuration for the policy. This block must be defined exactly once.

blocking boolean

A flag indicating if the policy should be blocking. Defaults to true.

enabled boolean

A flag indicating if the policy should be enabled. Defaults to true.

projectId string

The ID of the project in which the policy will be created.

settings BranchPolicyBuildValidationSettings

Configuration for the policy. This block must be defined exactly once.

blocking bool

A flag indicating if the policy should be blocking. Defaults to true.

enabled bool

A flag indicating if the policy should be enabled. Defaults to true.

project_id str

The ID of the project in which the policy will be created.

settings Dict[BranchPolicyBuildValidationSettings]

Configuration for the policy. This block must be defined exactly once.

Supporting Types

BranchPolicyBuildValidationSettings

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

BuildDefinitionId int

The ID of the build to monitor for the policy.

DisplayName string

The display name for the policy.

Scopes List<Pulumi.AzureDevOps.Policy.Inputs.BranchPolicyBuildValidationSettingsScopeArgs>

Controls which repositories and branches the policy will be enabled for. This block must be defined at least once.

ManualQueueOnly bool

If set to true, the build will need to be manually queued. Defaults to false

QueueOnSourceUpdateOnly bool

True if the build should queue on source updates only. Defaults to true.

ValidDuration int

The number of minutes for which the build is valid. If 0, the build will not expire. Defaults to 720 (12 hours).

BuildDefinitionId int

The ID of the build to monitor for the policy.

DisplayName string

The display name for the policy.

Scopes []BranchPolicyBuildValidationSettingsScope

Controls which repositories and branches the policy will be enabled for. This block must be defined at least once.

ManualQueueOnly bool

If set to true, the build will need to be manually queued. Defaults to false

QueueOnSourceUpdateOnly bool

True if the build should queue on source updates only. Defaults to true.

ValidDuration int

The number of minutes for which the build is valid. If 0, the build will not expire. Defaults to 720 (12 hours).

buildDefinitionId number

The ID of the build to monitor for the policy.

displayName string

The display name for the policy.

scopes BranchPolicyBuildValidationSettingsScope[]

Controls which repositories and branches the policy will be enabled for. This block must be defined at least once.

manualQueueOnly boolean

If set to true, the build will need to be manually queued. Defaults to false

queueOnSourceUpdateOnly boolean

True if the build should queue on source updates only. Defaults to true.

validDuration number

The number of minutes for which the build is valid. If 0, the build will not expire. Defaults to 720 (12 hours).

buildDefinitionId float

The ID of the build to monitor for the policy.

display_name str

The display name for the policy.

scopes List[BranchPolicyBuildValidationSettingsScope]

Controls which repositories and branches the policy will be enabled for. This block must be defined at least once.

manualQueueOnly bool

If set to true, the build will need to be manually queued. Defaults to false

queueOnSourceUpdateOnly bool

True if the build should queue on source updates only. Defaults to true.

validDuration float

The number of minutes for which the build is valid. If 0, the build will not expire. Defaults to 720 (12 hours).

BranchPolicyBuildValidationSettingsScope

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

MatchType string

The match type to use when applying the policy. Supported values are Exact (default) or Prefix.

RepositoryId string

The repository ID. Needed only if the scope of the policy will be limited to a single repository.

RepositoryRef string

The ref pattern to use for the match. If match_type is Exact, this should be a qualified ref such as refs/heads/master. If match_type is Prefix, this should be a ref path such as refs/heads/releases.

MatchType string

The match type to use when applying the policy. Supported values are Exact (default) or Prefix.

RepositoryId string

The repository ID. Needed only if the scope of the policy will be limited to a single repository.

RepositoryRef string

The ref pattern to use for the match. If match_type is Exact, this should be a qualified ref such as refs/heads/master. If match_type is Prefix, this should be a ref path such as refs/heads/releases.

matchType string

The match type to use when applying the policy. Supported values are Exact (default) or Prefix.

repositoryId string

The repository ID. Needed only if the scope of the policy will be limited to a single repository.

repositoryRef string

The ref pattern to use for the match. If match_type is Exact, this should be a qualified ref such as refs/heads/master. If match_type is Prefix, this should be a ref path such as refs/heads/releases.

matchType str

The match type to use when applying the policy. Supported values are Exact (default) or Prefix.

repositoryId str

The repository ID. Needed only if the scope of the policy will be limited to a single repository.

repositoryRef str

The ref pattern to use for the match. If match_type is Exact, this should be a qualified ref such as refs/heads/master. If match_type is Prefix, this should be a ref path such as refs/heads/releases.

Package Details

Repository
https://github.com/pulumi/pulumi-azuredevops
License
Apache-2.0
Notes
This Pulumi package is based on the azuredevops Terraform Provider.