AzureDevOps

Pulumi Official
Package maintained by Pulumi
v2.5.0 published on Monday, Jul 25, 2022 by Pulumi

BranchPolicyMergeTypes

Branch policy for merge types allowed on a specified branch.

Example Usage

using Pulumi;
using AzureDevOps = Pulumi.AzureDevOps;

class MyStack : Stack
{
    public MyStack()
    {
        var exampleProject = new AzureDevOps.Project("exampleProject", new AzureDevOps.ProjectArgs
        {
        });
        var exampleGit = new AzureDevOps.Git("exampleGit", new AzureDevOps.GitArgs
        {
            ProjectId = exampleProject.Id,
            Initialization = new AzureDevOps.Inputs.GitInitializationArgs
            {
                InitType = "Clean",
            },
        });
        var exampleBranchPolicyMergeTypes = new AzureDevOps.BranchPolicyMergeTypes("exampleBranchPolicyMergeTypes", new AzureDevOps.BranchPolicyMergeTypesArgs
        {
            ProjectId = exampleProject.Id,
            Enabled = true,
            Blocking = true,
            Settings = new AzureDevOps.Inputs.BranchPolicyMergeTypesSettingsArgs
            {
                AllowSquash = true,
                AllowRebaseAndFastForward = true,
                AllowBasicNoFastForward = true,
                AllowRebaseWithMerge = true,
                Scopes = 
                {
                    new AzureDevOps.Inputs.BranchPolicyMergeTypesSettingsScopeArgs
                    {
                        RepositoryId = exampleGit.Id,
                        RepositoryRef = exampleGit.DefaultBranch,
                        MatchType = "Exact",
                    },
                    new AzureDevOps.Inputs.BranchPolicyMergeTypesSettingsScopeArgs
                    {
                        RepositoryId = null,
                        RepositoryRef = "refs/heads/releases",
                        MatchType = "Prefix",
                    },
                    new AzureDevOps.Inputs.BranchPolicyMergeTypesSettingsScopeArgs
                    {
                        MatchType = "DefaultBranch",
                    },
                },
            },
        });
    }

}
package main

import (
	"github.com/pulumi/pulumi-azuredevops/sdk/v2/go/azuredevops"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		exampleProject, err := azuredevops.NewProject(ctx, "exampleProject", nil)
		if err != nil {
			return err
		}
		exampleGit, err := azuredevops.NewGit(ctx, "exampleGit", &azuredevops.GitArgs{
			ProjectId: exampleProject.ID(),
			Initialization: &GitInitializationArgs{
				InitType: pulumi.String("Clean"),
			},
		})
		if err != nil {
			return err
		}
		_, err = azuredevops.NewBranchPolicyMergeTypes(ctx, "exampleBranchPolicyMergeTypes", &azuredevops.BranchPolicyMergeTypesArgs{
			ProjectId: exampleProject.ID(),
			Enabled:   pulumi.Bool(true),
			Blocking:  pulumi.Bool(true),
			Settings: &BranchPolicyMergeTypesSettingsArgs{
				AllowSquash:               pulumi.Bool(true),
				AllowRebaseAndFastForward: pulumi.Bool(true),
				AllowBasicNoFastForward:   pulumi.Bool(true),
				AllowRebaseWithMerge:      pulumi.Bool(true),
				Scopes: BranchPolicyMergeTypesSettingsScopeArray{
					&BranchPolicyMergeTypesSettingsScopeArgs{
						RepositoryId:  exampleGit.ID(),
						RepositoryRef: exampleGit.DefaultBranch,
						MatchType:     pulumi.String("Exact"),
					},
					&BranchPolicyMergeTypesSettingsScopeArgs{
						RepositoryId:  nil,
						RepositoryRef: pulumi.String("refs/heads/releases"),
						MatchType:     pulumi.String("Prefix"),
					},
					&BranchPolicyMergeTypesSettingsScopeArgs{
						MatchType: pulumi.String("DefaultBranch"),
					},
				},
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azuredevops.Project;
import com.pulumi.azuredevops.Git;
import com.pulumi.azuredevops.GitArgs;
import com.pulumi.azuredevops.inputs.GitInitializationArgs;
import com.pulumi.azuredevops.BranchPolicyMergeTypes;
import com.pulumi.azuredevops.BranchPolicyMergeTypesArgs;
import com.pulumi.azuredevops.inputs.BranchPolicyMergeTypesSettingsArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var exampleProject = new Project("exampleProject");

        var exampleGit = new Git("exampleGit", GitArgs.builder()        
            .projectId(exampleProject.id())
            .initialization(GitInitializationArgs.builder()
                .initType("Clean")
                .build())
            .build());

        var exampleBranchPolicyMergeTypes = new BranchPolicyMergeTypes("exampleBranchPolicyMergeTypes", BranchPolicyMergeTypesArgs.builder()        
            .projectId(exampleProject.id())
            .enabled(true)
            .blocking(true)
            .settings(BranchPolicyMergeTypesSettingsArgs.builder()
                .allowSquash(true)
                .allowRebaseAndFastForward(true)
                .allowBasicNoFastForward(true)
                .allowRebaseWithMerge(true)
                .scopes(                
                    BranchPolicyMergeTypesSettingsScopeArgs.builder()
                        .repositoryId(exampleGit.id())
                        .repositoryRef(exampleGit.defaultBranch())
                        .matchType("Exact")
                        .build(),
                    BranchPolicyMergeTypesSettingsScopeArgs.builder()
                        .repositoryId(null)
                        .repositoryRef("refs/heads/releases")
                        .matchType("Prefix")
                        .build(),
                    BranchPolicyMergeTypesSettingsScopeArgs.builder()
                        .matchType("DefaultBranch")
                        .build())
                .build())
            .build());

    }
}
import pulumi
import pulumi_azuredevops as azuredevops

example_project = azuredevops.Project("exampleProject")
example_git = azuredevops.Git("exampleGit",
    project_id=example_project.id,
    initialization=azuredevops.GitInitializationArgs(
        init_type="Clean",
    ))
example_branch_policy_merge_types = azuredevops.BranchPolicyMergeTypes("exampleBranchPolicyMergeTypes",
    project_id=example_project.id,
    enabled=True,
    blocking=True,
    settings=azuredevops.BranchPolicyMergeTypesSettingsArgs(
        allow_squash=True,
        allow_rebase_and_fast_forward=True,
        allow_basic_no_fast_forward=True,
        allow_rebase_with_merge=True,
        scopes=[
            azuredevops.BranchPolicyMergeTypesSettingsScopeArgs(
                repository_id=example_git.id,
                repository_ref=example_git.default_branch,
                match_type="Exact",
            ),
            azuredevops.BranchPolicyMergeTypesSettingsScopeArgs(
                repository_id=None,
                repository_ref="refs/heads/releases",
                match_type="Prefix",
            ),
            azuredevops.BranchPolicyMergeTypesSettingsScopeArgs(
                match_type="DefaultBranch",
            ),
        ],
    ))
import * as pulumi from "@pulumi/pulumi";
import * as azuredevops from "@pulumi/azuredevops";

const exampleProject = new azuredevops.Project("exampleProject", {});
const exampleGit = new azuredevops.Git("exampleGit", {
    projectId: exampleProject.id,
    initialization: {
        initType: "Clean",
    },
});
const exampleBranchPolicyMergeTypes = new azuredevops.BranchPolicyMergeTypes("exampleBranchPolicyMergeTypes", {
    projectId: exampleProject.id,
    enabled: true,
    blocking: true,
    settings: {
        allowSquash: true,
        allowRebaseAndFastForward: true,
        allowBasicNoFastForward: true,
        allowRebaseWithMerge: true,
        scopes: [
            {
                repositoryId: exampleGit.id,
                repositoryRef: exampleGit.defaultBranch,
                matchType: "Exact",
            },
            {
                repositoryId: undefined,
                repositoryRef: "refs/heads/releases",
                matchType: "Prefix",
            },
            {
                matchType: "DefaultBranch",
            },
        ],
    },
});
resources:
  exampleProject:
    type: azuredevops:Project
  exampleGit:
    type: azuredevops:Git
    properties:
      projectId: ${exampleProject.id}
      initialization:
        initType: Clean
  exampleBranchPolicyMergeTypes:
    type: azuredevops:BranchPolicyMergeTypes
    properties:
      projectId: ${exampleProject.id}
      enabled: true
      blocking: true
      settings:
        allowSquash: true
        allowRebaseAndFastForward: true
        allowBasicNoFastForward: true
        allowRebaseWithMerge: true
        scopes:
          - repositoryId: ${exampleGit.id}
            repositoryRef: ${exampleGit.defaultBranch}
            matchType: Exact
          - repositoryId: null
            repositoryRef: refs/heads/releases
            matchType: Prefix
          - matchType: DefaultBranch

Create a BranchPolicyMergeTypes Resource

new BranchPolicyMergeTypes(name: string, args: BranchPolicyMergeTypesArgs, opts?: CustomResourceOptions);
@overload
def BranchPolicyMergeTypes(resource_name: str,
                           opts: Optional[ResourceOptions] = None,
                           blocking: Optional[bool] = None,
                           enabled: Optional[bool] = None,
                           project_id: Optional[str] = None,
                           settings: Optional[BranchPolicyMergeTypesSettingsArgs] = None)
@overload
def BranchPolicyMergeTypes(resource_name: str,
                           args: BranchPolicyMergeTypesArgs,
                           opts: Optional[ResourceOptions] = None)
func NewBranchPolicyMergeTypes(ctx *Context, name string, args BranchPolicyMergeTypesArgs, opts ...ResourceOption) (*BranchPolicyMergeTypes, error)
public BranchPolicyMergeTypes(string name, BranchPolicyMergeTypesArgs args, CustomResourceOptions? opts = null)
public BranchPolicyMergeTypes(String name, BranchPolicyMergeTypesArgs args)
public BranchPolicyMergeTypes(String name, BranchPolicyMergeTypesArgs args, CustomResourceOptions options)
type: azuredevops:BranchPolicyMergeTypes
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args BranchPolicyMergeTypesArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
args BranchPolicyMergeTypesArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args BranchPolicyMergeTypesArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args BranchPolicyMergeTypesArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args BranchPolicyMergeTypesArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

BranchPolicyMergeTypes Resource Properties

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

Inputs

The BranchPolicyMergeTypes resource accepts the following input properties:

ProjectId string

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

Settings Pulumi.AzureDevOps.Inputs.BranchPolicyMergeTypesSettingsArgs

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 BranchPolicyMergeTypesSettingsArgs

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 BranchPolicyMergeTypesSettingsArgs

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 BranchPolicyMergeTypesSettingsArgs

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 BranchPolicyMergeTypesSettingsArgs

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 Property Map

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.

Outputs

All input properties are implicitly available as output properties. Additionally, the BranchPolicyMergeTypes 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 string

The provider-assigned unique ID for this managed resource.

id str

The provider-assigned unique ID for this managed resource.

id String

The provider-assigned unique ID for this managed resource.

Look up an Existing BranchPolicyMergeTypes Resource

Get an existing BranchPolicyMergeTypes 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?: BranchPolicyMergeTypesState, opts?: CustomResourceOptions): BranchPolicyMergeTypes
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        blocking: Optional[bool] = None,
        enabled: Optional[bool] = None,
        project_id: Optional[str] = None,
        settings: Optional[BranchPolicyMergeTypesSettingsArgs] = None) -> BranchPolicyMergeTypes
func GetBranchPolicyMergeTypes(ctx *Context, name string, id IDInput, state *BranchPolicyMergeTypesState, opts ...ResourceOption) (*BranchPolicyMergeTypes, error)
public static BranchPolicyMergeTypes Get(string name, Input<string> id, BranchPolicyMergeTypesState? state, CustomResourceOptions? opts = null)
public static BranchPolicyMergeTypes get(String name, Output<String> id, BranchPolicyMergeTypesState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
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.
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.Inputs.BranchPolicyMergeTypesSettingsArgs

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 BranchPolicyMergeTypesSettingsArgs

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 BranchPolicyMergeTypesSettingsArgs

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 BranchPolicyMergeTypesSettingsArgs

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 BranchPolicyMergeTypesSettingsArgs

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 Property Map

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

Supporting Types

BranchPolicyMergeTypesSettings

Scopes List<Pulumi.AzureDevOps.Inputs.BranchPolicyMergeTypesSettingsScope>

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

AllowBasicNoFastForward bool

Allow basic merge with no fast forward. Defaults to false.

AllowRebaseAndFastForward bool

Allow rebase with fast forward. Defaults to false.

AllowRebaseWithMerge bool

Allow rebase with merge commit. Defaults to false.

AllowSquash bool

Allow squash merge. Defaults to false

Scopes []BranchPolicyMergeTypesSettingsScope

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

AllowBasicNoFastForward bool

Allow basic merge with no fast forward. Defaults to false.

AllowRebaseAndFastForward bool

Allow rebase with fast forward. Defaults to false.

AllowRebaseWithMerge bool

Allow rebase with merge commit. Defaults to false.

AllowSquash bool

Allow squash merge. Defaults to false

scopes List<BranchPolicyMergeTypesSettingsScope>

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

allowBasicNoFastForward Boolean

Allow basic merge with no fast forward. Defaults to false.

allowRebaseAndFastForward Boolean

Allow rebase with fast forward. Defaults to false.

allowRebaseWithMerge Boolean

Allow rebase with merge commit. Defaults to false.

allowSquash Boolean

Allow squash merge. Defaults to false

scopes BranchPolicyMergeTypesSettingsScope[]

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

allowBasicNoFastForward boolean

Allow basic merge with no fast forward. Defaults to false.

allowRebaseAndFastForward boolean

Allow rebase with fast forward. Defaults to false.

allowRebaseWithMerge boolean

Allow rebase with merge commit. Defaults to false.

allowSquash boolean

Allow squash merge. Defaults to false

scopes Sequence[BranchPolicyMergeTypesSettingsScope]

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

allow_basic_no_fast_forward bool

Allow basic merge with no fast forward. Defaults to false.

allow_rebase_and_fast_forward bool

Allow rebase with fast forward. Defaults to false.

allow_rebase_with_merge bool

Allow rebase with merge commit. Defaults to false.

allow_squash bool

Allow squash merge. Defaults to false

scopes List<Property Map>

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

allowBasicNoFastForward Boolean

Allow basic merge with no fast forward. Defaults to false.

allowRebaseAndFastForward Boolean

Allow rebase with fast forward. Defaults to false.

allowRebaseWithMerge Boolean

Allow rebase with merge commit. Defaults to false.

allowSquash Boolean

Allow squash merge. Defaults to false

BranchPolicyMergeTypesSettingsScope

MatchType string

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

RepositoryId string

The repository ID. Needed only if the scope of the policy will be limited to a single repository. If match_type is DefaultBranch, this should not be defined.

RepositoryRef string

The ref pattern to use for the match when match_type other than DefaultBranch. 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), Prefix or DefaultBranch.

RepositoryId string

The repository ID. Needed only if the scope of the policy will be limited to a single repository. If match_type is DefaultBranch, this should not be defined.

RepositoryRef string

The ref pattern to use for the match when match_type other than DefaultBranch. 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), Prefix or DefaultBranch.

repositoryId String

The repository ID. Needed only if the scope of the policy will be limited to a single repository. If match_type is DefaultBranch, this should not be defined.

repositoryRef String

The ref pattern to use for the match when match_type other than DefaultBranch. 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), Prefix or DefaultBranch.

repositoryId string

The repository ID. Needed only if the scope of the policy will be limited to a single repository. If match_type is DefaultBranch, this should not be defined.

repositoryRef string

The ref pattern to use for the match when match_type other than DefaultBranch. 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.

match_type str

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

repository_id str

The repository ID. Needed only if the scope of the policy will be limited to a single repository. If match_type is DefaultBranch, this should not be defined.

repository_ref str

The ref pattern to use for the match when match_type other than DefaultBranch. 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), Prefix or DefaultBranch.

repositoryId String

The repository ID. Needed only if the scope of the policy will be limited to a single repository. If match_type is DefaultBranch, this should not be defined.

repositoryRef String

The ref pattern to use for the match when match_type other than DefaultBranch. 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.

Import

Azure DevOps Branch Policies can be imported using the project ID and policy configuration ID

 $ pulumi import azuredevops:index/branchPolicyMergeTypes:BranchPolicyMergeTypes example 00000000-0000-0000-0000-000000000000/0

Package Details

Repository
https://github.com/pulumi/pulumi-azuredevops
License
Apache-2.0
Notes

This Pulumi package is based on the azuredevops Terraform Provider.