azuredevops_branch_policy_build_validation

Manages a build validation branch policy within Azure DevOps.

Example Usage

resource "azuredevops_project" "example" {
  name = "Example Project"
}

resource "azuredevops_git_repository" "example" {
  project_id = azuredevops_project.example.id
  name       = "Example Repository"
  initialization {
    init_type = "Clean"
  }
}

resource "azuredevops_build_definition" "example" {
  project_id = azuredevops_project.example.id
  name       = "Example Build Definition"

  repository {
    repo_type = "TfsGit"
    repo_id   = azuredevops_git_repository.example.id
    yml_path  = "azure-pipelines.yml"
  }
}

resource "azuredevops_branch_policy_build_validation" "example" {
  project_id = azuredevops_project.example.id

  enabled  = true
  blocking = true

  settings {
    display_name        = "Example build validation policy"
    build_definition_id = azuredevops_build_definition.example.id
    valid_duration      = 720
    filename_patterns = [
      "/WebApp/*",
      "!/WebApp/Tests/*",
      "*.cs"
    ]

    scope {
      repository_id  = azuredevops_git_repository.example.id
      repository_ref = azuredevops_git_repository.example.default_branch
      match_type     = "Exact"
    }

    scope {
      repository_id  = azuredevops_git_repository.example.id
      repository_ref = "refs/heads/releases"
      match_type     = "Prefix"
    }

    scope {
      match_type     = "DefaultBranch"
    }
  }
}

Argument Reference

The following arguments are supported:

A settings block supports the following:

A settings scope block supports the following:

Attributes Reference

In addition to all arguments above, the following attributes are exported:

Import

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

terraform import azuredevops_branch_policy_build_validation.example 00000000-0000-0000-0000-000000000000/0