UNPKG

@pulumi/azuredevops

Version:

A Pulumi package for creating and managing Azure DevOps.

408 lines 14.9 kB
"use strict"; // *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.BuildDefinition = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("./utilities"); /** * 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 * ``` */ 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, id, state, opts) { return new BuildDefinition(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * 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) { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === BuildDefinition.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["agentPoolName"] = state ? state.agentPoolName : undefined; resourceInputs["agentSpecification"] = state ? state.agentSpecification : undefined; resourceInputs["buildCompletionTriggers"] = state ? state.buildCompletionTriggers : undefined; resourceInputs["ciTrigger"] = state ? state.ciTrigger : undefined; resourceInputs["features"] = state ? state.features : undefined; resourceInputs["jobAuthorizationScope"] = state ? state.jobAuthorizationScope : undefined; resourceInputs["jobs"] = state ? state.jobs : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["path"] = state ? state.path : undefined; resourceInputs["projectId"] = state ? state.projectId : undefined; resourceInputs["pullRequestTrigger"] = state ? state.pullRequestTrigger : undefined; resourceInputs["queueStatus"] = state ? state.queueStatus : undefined; resourceInputs["repository"] = state ? state.repository : undefined; resourceInputs["revision"] = state ? state.revision : undefined; resourceInputs["schedules"] = state ? state.schedules : undefined; resourceInputs["variableGroups"] = state ? state.variableGroups : undefined; resourceInputs["variables"] = state ? state.variables : undefined; } else { const args = argsOrState; if ((!args || args.projectId === undefined) && !opts.urn) { throw new Error("Missing required property 'projectId'"); } if ((!args || args.repository === undefined) && !opts.urn) { throw new Error("Missing required property 'repository'"); } resourceInputs["agentPoolName"] = args ? args.agentPoolName : undefined; resourceInputs["agentSpecification"] = args ? args.agentSpecification : undefined; resourceInputs["buildCompletionTriggers"] = args ? args.buildCompletionTriggers : undefined; resourceInputs["ciTrigger"] = args ? args.ciTrigger : undefined; resourceInputs["features"] = args ? args.features : undefined; resourceInputs["jobAuthorizationScope"] = args ? args.jobAuthorizationScope : undefined; resourceInputs["jobs"] = args ? args.jobs : undefined; resourceInputs["name"] = args ? args.name : undefined; resourceInputs["path"] = args ? args.path : undefined; resourceInputs["projectId"] = args ? args.projectId : undefined; resourceInputs["pullRequestTrigger"] = args ? args.pullRequestTrigger : undefined; resourceInputs["queueStatus"] = args ? args.queueStatus : undefined; resourceInputs["repository"] = args ? args.repository : undefined; resourceInputs["schedules"] = args ? args.schedules : undefined; resourceInputs["variableGroups"] = args ? args.variableGroups : undefined; resourceInputs["variables"] = args ? args.variables : undefined; resourceInputs["revision"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(BuildDefinition.__pulumiType, name, resourceInputs, opts); } } exports.BuildDefinition = BuildDefinition; /** @internal */ BuildDefinition.__pulumiType = 'azuredevops:index/buildDefinition:BuildDefinition'; //# sourceMappingURL=buildDefinition.js.map