UNPKG

@pulumi/azuredevops

Version:

A Pulumi package for creating and managing Azure DevOps.

557 lines (556 loc) 19.3 kB
import * as pulumi from "@pulumi/pulumi"; import * as inputs from "./types/input"; import * as outputs from "./types/output"; /** * Manages a Build Definition within Azure DevOps. * * ## Example Usage * * ### Azure DevOps * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as azuredevops from "@pulumi/azuredevops"; * * const example = new azuredevops.Project("example", { * name: "Example Project", * visibility: "private", * versionControl: "Git", * workItemTemplate: "Agile", * }); * const exampleGit = new azuredevops.Git("example", { * projectId: example.id, * name: "Example Repository", * initialization: { * initType: "Clean", * }, * }); * const exampleVariableGroup = new azuredevops.VariableGroup("example", { * projectId: example.id, * name: "Example Pipeline Variables", * description: "Managed by Pulumi", * allowAccess: true, * variables: [{ * name: "FOO", * value: "BAR", * }], * }); * const exampleBuildDefinition = new azuredevops.BuildDefinition("example", { * projectId: example.id, * name: "Example Build Definition", * path: "\\ExampleFolder", * ciTrigger: { * useYaml: false, * }, * schedules: [{ * branchFilters: [{ * includes: ["master"], * excludes: [ * "test", * "regression", * ], * }], * daysToBuilds: [ * "Wed", * "Sun", * ], * scheduleOnlyWithChanges: true, * startHours: 10, * startMinutes: 59, * timeZone: "(UTC) Coordinated Universal Time", * }], * repository: { * repoType: "TfsGit", * repoId: exampleGit.id, * branchName: exampleGit.defaultBranch, * ymlPath: "azure-pipelines.yml", * }, * variableGroups: [exampleVariableGroup.id], * variables: [ * { * name: "PipelineVariable", * value: "Go Microsoft!", * }, * { * name: "PipelineSecret", * secretValue: "ZGV2cw", * isSecret: true, * }, * ], * }); * ``` * * ### GitHub Enterprise * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as azuredevops from "@pulumi/azuredevops"; * * const example = new azuredevops.Project("example", { * name: "Example Project", * visibility: "private", * versionControl: "Git", * workItemTemplate: "Agile", * }); * const exampleServiceEndpointGitHubEnterprise = new azuredevops.ServiceEndpointGitHubEnterprise("example", { * projectId: example.id, * serviceEndpointName: "Example GitHub Enterprise", * url: "https://github.contoso.com", * description: "Managed by Pulumi", * authPersonal: { * personalAccessToken: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", * }, * }); * const exampleBuildDefinition = new azuredevops.BuildDefinition("example", { * projectId: example.id, * name: "Example Build Definition", * path: "\\ExampleFolder", * ciTrigger: { * useYaml: false, * }, * repository: { * repoType: "GitHubEnterprise", * repoId: "<GitHub Org>/<Repo Name>", * githubEnterpriseUrl: "https://github.company.com", * branchName: "master", * ymlPath: "azure-pipelines.yml", * serviceConnectionId: exampleServiceEndpointGitHubEnterprise.id, * }, * schedules: [{ * branchFilters: [{ * includes: ["main"], * excludes: [ * "test", * "regression", * ], * }], * daysToBuilds: [ * "Wed", * "Sun", * ], * scheduleOnlyWithChanges: true, * startHours: 10, * startMinutes: 59, * timeZone: "(UTC) Coordinated Universal Time", * }], * }); * ``` * * ### Build Completion Trigger * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as azuredevops from "@pulumi/azuredevops"; * * const example = new azuredevops.BuildDefinition("example", { * projectId: exampleAzuredevopsProject.id, * name: "Example Build Definition", * path: "\\ExampleFolder", * ciTrigger: { * useYaml: false, * }, * repository: { * repoType: "GitHubEnterprise", * repoId: "<GitHub Org>/<Repo Name>", * githubEnterpriseUrl: "https://github.company.com", * branchName: "main", * ymlPath: "azure-pipelines.yml", * serviceConnectionId: exampleAzuredevopsServiceendpointGithubEnterprise.id, * }, * buildCompletionTriggers: [{ * buildDefinitionId: 10, * branchFilters: [{ * includes: ["main"], * excludes: ["test"], * }], * }], * }); * ``` * * ### Pull Request Trigger * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as azuredevops from "@pulumi/azuredevops"; * * const example = azuredevops.getServiceEndpointGithub({ * projectId: exampleAzuredevopsProject.id, * serviceEndpointId: "00000000-0000-0000-0000-000000000000", * }); * const exampleBuildDefinition = new azuredevops.BuildDefinition("example", { * projectId: exampleAzuredevopsProject2.id, * name: "Example Build Definition", * path: "\\ExampleFolder", * ciTrigger: { * useYaml: false, * }, * repository: { * repoType: "GitHub", * repoId: "<GitHub Org>/<Repo Name>", * branchName: "main", * ymlPath: "azure-pipelines.yml", * serviceConnectionId: example.then(example => example.id), * }, * pullRequestTrigger: { * override: { * branchFilters: [{ * includes: ["main"], * }], * }, * forks: { * enabled: false, * shareSecrets: false, * }, * }, * }); * ``` * * ### Using Other Git and Agent Jobs * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as azuredevops from "@pulumi/azuredevops"; * * const example = new azuredevops.ServiceEndpointGenericGit("example", { * projectId: exampleAzuredevopsProject.id, * repositoryUrl: "https://gitlab.com/example/example.git", * password: "token", * serviceEndpointName: "Example Generic Git", * }); * const exampleBuildDefinition = new azuredevops.BuildDefinition("example", { * projectId: exampleAzuredevopsProject2.id, * name: "Example Build Definition", * path: "\\ExampleFolder", * ciTrigger: { * useYaml: false, * }, * repository: { * repoType: "Git", * repoId: example.repositoryUrl, * branchName: "refs/heads/main", * url: example.repositoryUrl, * serviceConnectionId: example.id, * }, * jobs: [ * { * name: "Agent Job1", * refName: "agent_job1", * condition: "succeededOrFailed()", * target: { * type: "AgentJob", * executionOptions: { * type: "None", * }, * }, * }, * { * name: "Agent Job2", * refName: "agent_job2", * condition: "succeededOrFailed()", * dependencies: [{ * scope: "agent_job1", * }], * target: { * type: "AgentJob", * demands: ["git"], * executionOptions: { * type: "Multi-Configuration", * continueOnError: true, * multipliers: "multipliers", * maxConcurrency: 2, * }, * }, * }, * { * name: "Agentless Job1", * refName: "agentless_job1", * condition: "succeeded()", * target: { * type: "AgentlessJob", * executionOptions: { * type: "None", * }, * }, * }, * { * name: "Agentless Job2", * refName: "agentless_job2", * condition: "succeeded()", * jobAuthorizationScope: "project", * dependencies: [ * { * scope: "agent_job2", * }, * { * scope: "agentless_job1", * }, * ], * target: { * type: "AgentlessJob", * executionOptions: { * type: "Multi-Configuration", * continueOnError: true, * multipliers: "multipliers", * }, * }, * }, * ], * }); * ``` * * ## Remarks * * The path attribute can not end in `\` unless the path is the root value of `\`. * * Valid path values (yaml encoded) include: * - `\\` * - `\\ExampleFolder` * - `\\Nested\\Example Folder` * * The value of `\\ExampleFolder\\` would be invalid. * * ## Relevant Links * * - [Azure DevOps Service REST API 7.0 - Build Definitions](https://docs.microsoft.com/en-us/rest/api/azure/devops/build/definitions?view=azure-devops-rest-7.0) * * ## Import * * Azure DevOps Build Definitions can be imported using the project name/definitions Id or by the project Guid/definitions Id, e.g. * * ```sh * $ pulumi import azuredevops:index/buildDefinition:BuildDefinition example "Example Project"/10 * ``` * * or * * ```sh * $ pulumi import azuredevops:index/buildDefinition:BuildDefinition example 00000000-0000-0000-0000-000000000000/0 * ``` */ export declare class BuildDefinition extends pulumi.CustomResource { /** * Get an existing BuildDefinition resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name: string, id: pulumi.Input<pulumi.ID>, state?: BuildDefinitionState, opts?: pulumi.CustomResourceOptions): BuildDefinition; /** * Returns true if the given object is an instance of BuildDefinition. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj: any): obj is BuildDefinition; /** * The agent pool that should execute the build. Defaults to `Azure Pipelines`. */ readonly agentPoolName: pulumi.Output<string | undefined>; /** * The Agent Specification to run the pipelines. Required when `repoType` is `Git`. Example: `windows-2019`, `windows-latest`, `macos-13` etc. */ readonly agentSpecification: pulumi.Output<string | undefined>; /** * A `buildCompletionTrigger` block as documented below. */ readonly buildCompletionTriggers: pulumi.Output<outputs.BuildDefinitionBuildCompletionTrigger[] | undefined>; /** * A `ciTrigger` block as documented below. */ readonly ciTrigger: pulumi.Output<outputs.BuildDefinitionCiTrigger | undefined>; /** * A `features` blocks as documented below. */ readonly features: pulumi.Output<outputs.BuildDefinitionFeature[] | undefined>; /** * The job authorization scope for builds queued against this definition. Possible values are: `project`, `projectCollection`. Defaults to `projectCollection`. */ readonly jobAuthorizationScope: pulumi.Output<string | undefined>; /** * A `jobs` blocks as documented below. * * > **NOTE:** The `jobs` are classic pipelines, you need to enable the classic pipeline feature for your organization to use this feature. */ readonly jobs: pulumi.Output<outputs.BuildDefinitionJob[] | undefined>; /** * The name of the build definition. */ readonly name: pulumi.Output<string>; /** * The folder path of the build definition. */ readonly path: pulumi.Output<string | undefined>; /** * The project ID or project name. */ readonly projectId: pulumi.Output<string>; /** * A `pullRequestTrigger` block as documented below. */ readonly pullRequestTrigger: pulumi.Output<outputs.BuildDefinitionPullRequestTrigger | undefined>; /** * The queue status of the build definition. Possible values are: `enabled` or `paused` or `disabled`. Defaults to `enabled`. */ readonly queueStatus: pulumi.Output<string | undefined>; /** * A `repository` block as documented below. */ readonly repository: pulumi.Output<outputs.BuildDefinitionRepository>; /** * The revision of the build definition */ readonly revision: pulumi.Output<number>; readonly schedules: pulumi.Output<outputs.BuildDefinitionSchedule[] | undefined>; /** * A list of variable group IDs (integers) to link to the build definition. */ readonly variableGroups: pulumi.Output<number[] | undefined>; /** * A list of `variable` blocks, as documented below. */ readonly variables: pulumi.Output<outputs.BuildDefinitionVariable[] | undefined>; /** * Create a BuildDefinition resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: BuildDefinitionArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering BuildDefinition resources. */ export interface BuildDefinitionState { /** * The agent pool that should execute the build. Defaults to `Azure Pipelines`. */ agentPoolName?: pulumi.Input<string>; /** * The Agent Specification to run the pipelines. Required when `repoType` is `Git`. Example: `windows-2019`, `windows-latest`, `macos-13` etc. */ agentSpecification?: pulumi.Input<string>; /** * A `buildCompletionTrigger` block as documented below. */ buildCompletionTriggers?: pulumi.Input<pulumi.Input<inputs.BuildDefinitionBuildCompletionTrigger>[]>; /** * A `ciTrigger` block as documented below. */ ciTrigger?: pulumi.Input<inputs.BuildDefinitionCiTrigger>; /** * A `features` blocks as documented below. */ features?: pulumi.Input<pulumi.Input<inputs.BuildDefinitionFeature>[]>; /** * The job authorization scope for builds queued against this definition. Possible values are: `project`, `projectCollection`. Defaults to `projectCollection`. */ jobAuthorizationScope?: pulumi.Input<string>; /** * A `jobs` blocks as documented below. * * > **NOTE:** The `jobs` are classic pipelines, you need to enable the classic pipeline feature for your organization to use this feature. */ jobs?: pulumi.Input<pulumi.Input<inputs.BuildDefinitionJob>[]>; /** * The name of the build definition. */ name?: pulumi.Input<string>; /** * The folder path of the build definition. */ path?: pulumi.Input<string>; /** * The project ID or project name. */ projectId?: pulumi.Input<string>; /** * A `pullRequestTrigger` block as documented below. */ pullRequestTrigger?: pulumi.Input<inputs.BuildDefinitionPullRequestTrigger>; /** * The queue status of the build definition. Possible values are: `enabled` or `paused` or `disabled`. Defaults to `enabled`. */ queueStatus?: pulumi.Input<string>; /** * A `repository` block as documented below. */ repository?: pulumi.Input<inputs.BuildDefinitionRepository>; /** * The revision of the build definition */ revision?: pulumi.Input<number>; schedules?: pulumi.Input<pulumi.Input<inputs.BuildDefinitionSchedule>[]>; /** * A list of variable group IDs (integers) to link to the build definition. */ variableGroups?: pulumi.Input<pulumi.Input<number>[]>; /** * A list of `variable` blocks, as documented below. */ variables?: pulumi.Input<pulumi.Input<inputs.BuildDefinitionVariable>[]>; } /** * The set of arguments for constructing a BuildDefinition resource. */ export interface BuildDefinitionArgs { /** * The agent pool that should execute the build. Defaults to `Azure Pipelines`. */ agentPoolName?: pulumi.Input<string>; /** * The Agent Specification to run the pipelines. Required when `repoType` is `Git`. Example: `windows-2019`, `windows-latest`, `macos-13` etc. */ agentSpecification?: pulumi.Input<string>; /** * A `buildCompletionTrigger` block as documented below. */ buildCompletionTriggers?: pulumi.Input<pulumi.Input<inputs.BuildDefinitionBuildCompletionTrigger>[]>; /** * A `ciTrigger` block as documented below. */ ciTrigger?: pulumi.Input<inputs.BuildDefinitionCiTrigger>; /** * A `features` blocks as documented below. */ features?: pulumi.Input<pulumi.Input<inputs.BuildDefinitionFeature>[]>; /** * The job authorization scope for builds queued against this definition. Possible values are: `project`, `projectCollection`. Defaults to `projectCollection`. */ jobAuthorizationScope?: pulumi.Input<string>; /** * A `jobs` blocks as documented below. * * > **NOTE:** The `jobs` are classic pipelines, you need to enable the classic pipeline feature for your organization to use this feature. */ jobs?: pulumi.Input<pulumi.Input<inputs.BuildDefinitionJob>[]>; /** * The name of the build definition. */ name?: pulumi.Input<string>; /** * The folder path of the build definition. */ path?: pulumi.Input<string>; /** * The project ID or project name. */ projectId: pulumi.Input<string>; /** * A `pullRequestTrigger` block as documented below. */ pullRequestTrigger?: pulumi.Input<inputs.BuildDefinitionPullRequestTrigger>; /** * The queue status of the build definition. Possible values are: `enabled` or `paused` or `disabled`. Defaults to `enabled`. */ queueStatus?: pulumi.Input<string>; /** * A `repository` block as documented below. */ repository: pulumi.Input<inputs.BuildDefinitionRepository>; schedules?: pulumi.Input<pulumi.Input<inputs.BuildDefinitionSchedule>[]>; /** * A list of variable group IDs (integers) to link to the build definition. */ variableGroups?: pulumi.Input<pulumi.Input<number>[]>; /** * A list of `variable` blocks, as documented below. */ variables?: pulumi.Input<pulumi.Input<inputs.BuildDefinitionVariable>[]>; }