layout | page_title | description |
---|---|---|
azuredevops |
AzureDevops: azuredevops_build_definition |
Manages a Build Definition within Azure DevOps organization. |
Manages a Build Definition within Azure DevOps.
resource "azuredevops_project" "project" {
name = "Sample Project"
visibility = "private"
version_control = "Git"
work_item_template = "Agile"
}
resource "azuredevops_git_repository" "repository" {
project_id = azuredevops_project.project.id
name = "Sample Repository"
initialization {
init_type = "Clean"
}
}
resource "azuredevops_variable_group" "vars" {
project_id = azuredevops_project.project.id
name = "Infrastructure Pipeline Variables"
description = "Managed by Terraform"
allow_access = true
variable {
name = "FOO"
value = "BAR"
}
}
resource "azuredevops_build_definition" "build" {
project_id = azuredevops_project.project.id
name = "Sample Build Definition"
path = "\\ExampleFolder"
ci_trigger {
use_yaml = true
}
repository {
repo_type = "TfsGit"
repo_id = azuredevops_git_repository.repository.id
branch_name = azuredevops_git_repository.repository.default_branch
yml_path = "azure-pipelines.yml"
}
variable_groups = [
azuredevops_variable_group.vars.id
]
variable {
name = "PipelineVariable"
value = "Go Microsoft!"
}
variable {
name = "PipelineSecret"
secret_value = "ZGV2cw"
is_secret = true
}
}
resource "azuredevops_build_definition" "sample_dotnetcore_app_release" {
project_id = azuredevops_project.project.id
name = "Sample Build Definition"
path = "\\ExampleFolder"
ci_trigger {
use_yaml = true
}
repository {
repo_type = "GitHubEnterprise"
repo_id = "<GitHub Org>/<Repo Name>"
github_enterprise_url = "https://github.company.com"
branch_name = "master"
yml_path = "azure-pipelines.yml"
service_connection_id = "..."
}
}
The following arguments are supported:
project_id
- (Required) The project ID or project name.name
- (Optional) The name of the build definition.path
- (Optional) The folder path of the build definition.agent_pool_name
- (Optional) The agent pool that should execute the build.repository
- (Required) Arepository
block as documented below.ci_trigger
- (Optional) Continuous Integration trigger.pull_request_trigger
- (Optional) Pull Request Integration Integration trigger.variable_groups
- (Optional) A list of variable group IDs (integers) to link to the build definition.variable
- (Optional) A list ofvariable
blocks, as documented below.
variable
block supports the following:
name
- (Required) The name of the variable.value
- (Optional) The value of the variable.secret_value
- (Optional) The secret value of the variable. Used whenis_secret
set totrue
.is_secret
- (Optional) True if the variable is a secret. Defaults tofalse
.allow_override
- (Optional) True if the variable can be overridden. Defaults totrue
.
repository
block supports the following:
branch_name
- (Optional) The branch name for which builds are triggered. Defaults tomaster
.repo_id
- (Required) The id of the repository. ForTfsGit
repos, this is simply the ID of the repository. ForGithub
repos, this will take the form of<GitHub Org>/<Repo Name>
. ForBitbucket
repos, this will take the form of<Workspace ID>/<Repo Name>
.repo_type
- (Optional) The repository type. Valid values:GitHub
orTfsGit
orBitbucket
orGitHub Enterprise
. Defaults toGitHub
. Ifrepo_type
isGitHubEnterprise
, must use existing project and GitHub Enterprise service connection.service_connection_id
- (Optional) The service connection ID. Used if therepo_type
isGitHub
orGitHubEnterprise
.yml_path
- (Required) The path of the Yaml file describing the build definition.github_enterprise_url
- (Optional) The Github Enterprise URL. Used ifrepo_type
isGithubEnterprise
.report_build_status
- (Optional) Report build status. Default is true.
ci_trigger
block supports the following:
use_yaml
- (Optional) Use the azure-pipeline file for the build configuration. Defaults tofalse
.override
- (Optional) Override the azure-pipeline file and use a this configuration for all builds.
ci_trigger
override
block supports the following:
batch
- (Optional) If you set batch to true, when a pipeline is running, the system waits until the run is completed, then starts another run with all changes that have not yet been built. Defaults totrue
.branch_filter
- (Optional) The branches to include and exclude from the trigger.path_filter
- (Optional) Specify file paths to include or exclude. Note that the wildcard syntax is different between branches/tags and file paths.max_concurrent_builds_per_branch
- (Optional) The number of max builds per branch. Defaults to1
.polling_interval
- (Optional) How often the external repository is polled. Defaults to0
.polling_job_id
- (Computed) This is the ID of the polling job that polls the external repository. Once the build definition is saved/updated, this value is set.
pull_request_trigger
block supports the following:
use_yaml
- (Optional) Use the azure-pipeline file for the build configuration. Defaults tofalse
.initial_branch
- (Optional) When use_yaml is true set this to the name of the branch that the azure-pipelines.yml exists on. Defaults toManaged by Terraform
.forks
- (Required) Set permissions for Forked repositories.override
- (Optional) Override the azure-pipeline file and use this configuration for all builds.
forks
block supports the following:
enabled
- (Required) Build pull requests form forms of this repository.share_secrets
- (Required) Make secrets available to builds of forks.
pull_request_trigger
override
block supports the following:
-
auto_cancel
- (Optional) . Defaults totrue
. -
branch_filter
- (Optional) The branches to include and exclude from the trigger. -
path_filter
- (Optional) Specify file paths to include or exclude. Note that the wildcard syntax is different between branches/tags and file paths. -
branch_filter
block supports the following: -
include
- (Optional) List of branch patterns to include. -
exclude
- (Optional) List of branch patterns to exclude. -
path_filter
block supports the following: -
include
- (Optional) List of path patterns to include. -
exclude
- (Optional) List of path patterns to exclude.
In addition to all arguments above, the following attributes are exported:
id
- The ID of the build definitionrevision
- The revision of the build definition
Azure DevOps Build Definitions can be imported using the project name/definitions Id or by the project Guid/definitions Id, e.g.
$ terraform import azuredevops_build_definition.build "Test Project"/10
or
$ terraform import azuredevops_build_definition.build 00000000-0000-0000-0000-000000000000/0