BranchPolicyBuildValidation
Manages a build validation branch policy within Azure DevOps.
Relevant Links
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
new BranchPolicyBuildValidation(name: string, args: BranchPolicyBuildValidationArgs, opts?: CustomResourceOptions);def BranchPolicyBuildValidation(resource_name, opts=None, blocking=None, enabled=None, project_id=None, settings=None, __props__=None);func NewBranchPolicyBuildValidation(ctx *Context, name string, args BranchPolicyBuildValidationArgs, opts ...ResourceOption) (*BranchPolicyBuildValidation, error)public BranchPolicyBuildValidation(string name, BranchPolicyBuildValidationArgs args, CustomResourceOptions? opts = null)- 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:
- Project
Id string The ID of the project in which the policy will be created.
- Settings
Pulumi.
Azure Dev Ops. Policy. Inputs. Branch Policy Build Validation Settings Args 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 string The ID of the project in which the policy will be created.
- Settings
Branch
Policy Build Validation Settings 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 string The ID of the project in which the policy will be created.
- settings
Branch
Policy Build Validation Settings 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[Branch
Policy Build Validation Settings] 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:
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.
public static get(name: string, id: Input<ID>, state?: BranchPolicyBuildValidationState, opts?: CustomResourceOptions): BranchPolicyBuildValidationstatic 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)public static BranchPolicyBuildValidation Get(string name, Input<string> id, BranchPolicyBuildValidationState? state, CustomResourceOptions? opts = null)- 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.- Project
Id string The ID of the project in which the policy will be created.
- Settings
Pulumi.
Azure Dev Ops. Policy. Inputs. Branch Policy Build Validation Settings Args 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 string The ID of the project in which the policy will be created.
- Settings
Branch
Policy Build Validation Settings 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 string The ID of the project in which the policy will be created.
- settings
Branch
Policy Build Validation Settings 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[Branch
Policy Build Validation Settings] Configuration for the policy. This block must be defined exactly once.
Supporting Types
BranchPolicyBuildValidationSettings
- Build
Definition intId The ID of the build to monitor for the policy.
- Display
Name string The display name for the policy.
- Scopes
List<Pulumi.
Azure Dev Ops. Policy. Inputs. Branch Policy Build Validation Settings Scope Args> Controls which repositories and branches the policy will be enabled for. This block must be defined at least once.
- Manual
Queue boolOnly If set to true, the build will need to be manually queued. Defaults to
false- Queue
On boolSource Update Only True if the build should queue on source updates only. Defaults to
true.- Valid
Duration int The number of minutes for which the build is valid. If
0, the build will not expire. Defaults to720(12 hours).
- Build
Definition intId The ID of the build to monitor for the policy.
- Display
Name string The display name for the policy.
- Scopes
[]Branch
Policy Build Validation Settings Scope Controls which repositories and branches the policy will be enabled for. This block must be defined at least once.
- Manual
Queue boolOnly If set to true, the build will need to be manually queued. Defaults to
false- Queue
On boolSource Update Only True if the build should queue on source updates only. Defaults to
true.- Valid
Duration int The number of minutes for which the build is valid. If
0, the build will not expire. Defaults to720(12 hours).
- build
Definition numberId The ID of the build to monitor for the policy.
- display
Name string The display name for the policy.
- scopes
Branch
Policy Build Validation Settings Scope[] Controls which repositories and branches the policy will be enabled for. This block must be defined at least once.
- manual
Queue booleanOnly If set to true, the build will need to be manually queued. Defaults to
false- queue
On booleanSource Update Only True if the build should queue on source updates only. Defaults to
true.- valid
Duration number The number of minutes for which the build is valid. If
0, the build will not expire. Defaults to720(12 hours).
- build
Definition floatId The ID of the build to monitor for the policy.
- display_
name str The display name for the policy.
- scopes
List[Branch
Policy Build Validation Settings Scope] Controls which repositories and branches the policy will be enabled for. This block must be defined at least once.
- manual
Queue boolOnly If set to true, the build will need to be manually queued. Defaults to
false- queue
On boolSource Update Only True if the build should queue on source updates only. Defaults to
true.- valid
Duration float The number of minutes for which the build is valid. If
0, the build will not expire. Defaults to720(12 hours).
BranchPolicyBuildValidationSettingsScope
- Match
Type string The match type to use when applying the policy. Supported values are
Exact(default) orPrefix.- Repository
Id string The repository ID. Needed only if the scope of the policy will be limited to a single repository.
- Repository
Ref string The ref pattern to use for the match. If
match_typeisExact, this should be a qualified ref such asrefs/heads/master. Ifmatch_typeisPrefix, this should be a ref path such asrefs/heads/releases.
- Match
Type string The match type to use when applying the policy. Supported values are
Exact(default) orPrefix.- Repository
Id string The repository ID. Needed only if the scope of the policy will be limited to a single repository.
- Repository
Ref string The ref pattern to use for the match. If
match_typeisExact, this should be a qualified ref such asrefs/heads/master. Ifmatch_typeisPrefix, this should be a ref path such asrefs/heads/releases.
- match
Type string The match type to use when applying the policy. Supported values are
Exact(default) orPrefix.- repository
Id string The repository ID. Needed only if the scope of the policy will be limited to a single repository.
- repository
Ref string The ref pattern to use for the match. If
match_typeisExact, this should be a qualified ref such asrefs/heads/master. Ifmatch_typeisPrefix, this should be a ref path such asrefs/heads/releases.
- match
Type str The match type to use when applying the policy. Supported values are
Exact(default) orPrefix.- repository
Id str The repository ID. Needed only if the scope of the policy will be limited to a single repository.
- repository
Ref str The ref pattern to use for the match. If
match_typeisExact, this should be a qualified ref such asrefs/heads/master. Ifmatch_typeisPrefix, this should be a ref path such asrefs/heads/releases.
Package Details
- Repository
- https://github.com/pulumi/pulumi-azuredevops
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
azuredevopsTerraform Provider.