1. Packages
  2. AzureDevOps
  3. API Docs
  4. GitRepositoryBranch
Azure DevOps v3.1.1 published on Monday, May 20, 2024 by Pulumi

azuredevops.GitRepositoryBranch

Explore with Pulumi AI

azuredevops logo
Azure DevOps v3.1.1 published on Monday, May 20, 2024 by Pulumi

    Manages a Git Repository Branch.

    Example Usage

    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 Git Repository",
        initialization: {
            initType: "Clean",
        },
    });
    const exampleGitRepositoryBranch = new azuredevops.GitRepositoryBranch("example", {
        repositoryId: exampleGit.id,
        name: "example-branch-name",
        refBranch: exampleGit.defaultBranch,
    });
    const exampleFromCommitId = new azuredevops.GitRepositoryBranch("example_from_commit_id", {
        repositoryId: exampleGit.id,
        name: "example-from-commit-id",
        refCommitId: exampleGitRepositoryBranch.lastCommitId,
    });
    
    import pulumi
    import pulumi_azuredevops as azuredevops
    
    example = azuredevops.Project("example",
        name="Example Project",
        visibility="private",
        version_control="Git",
        work_item_template="Agile")
    example_git = azuredevops.Git("example",
        project_id=example.id,
        name="Example Git Repository",
        initialization=azuredevops.GitInitializationArgs(
            init_type="Clean",
        ))
    example_git_repository_branch = azuredevops.GitRepositoryBranch("example",
        repository_id=example_git.id,
        name="example-branch-name",
        ref_branch=example_git.default_branch)
    example_from_commit_id = azuredevops.GitRepositoryBranch("example_from_commit_id",
        repository_id=example_git.id,
        name="example-from-commit-id",
        ref_commit_id=example_git_repository_branch.last_commit_id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-azuredevops/sdk/v3/go/azuredevops"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		example, err := azuredevops.NewProject(ctx, "example", &azuredevops.ProjectArgs{
    			Name:             pulumi.String("Example Project"),
    			Visibility:       pulumi.String("private"),
    			VersionControl:   pulumi.String("Git"),
    			WorkItemTemplate: pulumi.String("Agile"),
    		})
    		if err != nil {
    			return err
    		}
    		exampleGit, err := azuredevops.NewGit(ctx, "example", &azuredevops.GitArgs{
    			ProjectId: example.ID(),
    			Name:      pulumi.String("Example Git Repository"),
    			Initialization: &azuredevops.GitInitializationArgs{
    				InitType: pulumi.String("Clean"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		exampleGitRepositoryBranch, err := azuredevops.NewGitRepositoryBranch(ctx, "example", &azuredevops.GitRepositoryBranchArgs{
    			RepositoryId: exampleGit.ID(),
    			Name:         pulumi.String("example-branch-name"),
    			RefBranch:    exampleGit.DefaultBranch,
    		})
    		if err != nil {
    			return err
    		}
    		_, err = azuredevops.NewGitRepositoryBranch(ctx, "example_from_commit_id", &azuredevops.GitRepositoryBranchArgs{
    			RepositoryId: exampleGit.ID(),
    			Name:         pulumi.String("example-from-commit-id"),
    			RefCommitId:  exampleGitRepositoryBranch.LastCommitId,
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AzureDevOps = Pulumi.AzureDevOps;
    
    return await Deployment.RunAsync(() => 
    {
        var example = new AzureDevOps.Project("example", new()
        {
            Name = "Example Project",
            Visibility = "private",
            VersionControl = "Git",
            WorkItemTemplate = "Agile",
        });
    
        var exampleGit = new AzureDevOps.Git("example", new()
        {
            ProjectId = example.Id,
            Name = "Example Git Repository",
            Initialization = new AzureDevOps.Inputs.GitInitializationArgs
            {
                InitType = "Clean",
            },
        });
    
        var exampleGitRepositoryBranch = new AzureDevOps.GitRepositoryBranch("example", new()
        {
            RepositoryId = exampleGit.Id,
            Name = "example-branch-name",
            RefBranch = exampleGit.DefaultBranch,
        });
    
        var exampleFromCommitId = new AzureDevOps.GitRepositoryBranch("example_from_commit_id", new()
        {
            RepositoryId = exampleGit.Id,
            Name = "example-from-commit-id",
            RefCommitId = exampleGitRepositoryBranch.LastCommitId,
        });
    
    });
    
    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.ProjectArgs;
    import com.pulumi.azuredevops.Git;
    import com.pulumi.azuredevops.GitArgs;
    import com.pulumi.azuredevops.inputs.GitInitializationArgs;
    import com.pulumi.azuredevops.GitRepositoryBranch;
    import com.pulumi.azuredevops.GitRepositoryBranchArgs;
    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 example = new Project("example", ProjectArgs.builder()        
                .name("Example Project")
                .visibility("private")
                .versionControl("Git")
                .workItemTemplate("Agile")
                .build());
    
            var exampleGit = new Git("exampleGit", GitArgs.builder()        
                .projectId(example.id())
                .name("Example Git Repository")
                .initialization(GitInitializationArgs.builder()
                    .initType("Clean")
                    .build())
                .build());
    
            var exampleGitRepositoryBranch = new GitRepositoryBranch("exampleGitRepositoryBranch", GitRepositoryBranchArgs.builder()        
                .repositoryId(exampleGit.id())
                .name("example-branch-name")
                .refBranch(exampleGit.defaultBranch())
                .build());
    
            var exampleFromCommitId = new GitRepositoryBranch("exampleFromCommitId", GitRepositoryBranchArgs.builder()        
                .repositoryId(exampleGit.id())
                .name("example-from-commit-id")
                .refCommitId(exampleGitRepositoryBranch.lastCommitId())
                .build());
    
        }
    }
    
    resources:
      example:
        type: azuredevops:Project
        properties:
          name: Example Project
          visibility: private
          versionControl: Git
          workItemTemplate: Agile
      exampleGit:
        type: azuredevops:Git
        name: example
        properties:
          projectId: ${example.id}
          name: Example Git Repository
          initialization:
            initType: Clean
      exampleGitRepositoryBranch:
        type: azuredevops:GitRepositoryBranch
        name: example
        properties:
          repositoryId: ${exampleGit.id}
          name: example-branch-name
          refBranch: ${exampleGit.defaultBranch}
      exampleFromCommitId:
        type: azuredevops:GitRepositoryBranch
        name: example_from_commit_id
        properties:
          repositoryId: ${exampleGit.id}
          name: example-from-commit-id
          refCommitId: ${exampleGitRepositoryBranch.lastCommitId}
    

    Create GitRepositoryBranch Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new GitRepositoryBranch(name: string, args: GitRepositoryBranchArgs, opts?: CustomResourceOptions);
    @overload
    def GitRepositoryBranch(resource_name: str,
                            args: GitRepositoryBranchArgs,
                            opts: Optional[ResourceOptions] = None)
    
    @overload
    def GitRepositoryBranch(resource_name: str,
                            opts: Optional[ResourceOptions] = None,
                            repository_id: Optional[str] = None,
                            name: Optional[str] = None,
                            ref_branch: Optional[str] = None,
                            ref_commit_id: Optional[str] = None,
                            ref_tag: Optional[str] = None)
    func NewGitRepositoryBranch(ctx *Context, name string, args GitRepositoryBranchArgs, opts ...ResourceOption) (*GitRepositoryBranch, error)
    public GitRepositoryBranch(string name, GitRepositoryBranchArgs args, CustomResourceOptions? opts = null)
    public GitRepositoryBranch(String name, GitRepositoryBranchArgs args)
    public GitRepositoryBranch(String name, GitRepositoryBranchArgs args, CustomResourceOptions options)
    
    type: azuredevops:GitRepositoryBranch
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args GitRepositoryBranchArgs
    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 GitRepositoryBranchArgs
    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 GitRepositoryBranchArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args GitRepositoryBranchArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args GitRepositoryBranchArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var gitRepositoryBranchResource = new AzureDevOps.GitRepositoryBranch("gitRepositoryBranchResource", new()
    {
        RepositoryId = "string",
        Name = "string",
        RefBranch = "string",
        RefCommitId = "string",
        RefTag = "string",
    });
    
    example, err := azuredevops.NewGitRepositoryBranch(ctx, "gitRepositoryBranchResource", &azuredevops.GitRepositoryBranchArgs{
    	RepositoryId: pulumi.String("string"),
    	Name:         pulumi.String("string"),
    	RefBranch:    pulumi.String("string"),
    	RefCommitId:  pulumi.String("string"),
    	RefTag:       pulumi.String("string"),
    })
    
    var gitRepositoryBranchResource = new GitRepositoryBranch("gitRepositoryBranchResource", GitRepositoryBranchArgs.builder()
        .repositoryId("string")
        .name("string")
        .refBranch("string")
        .refCommitId("string")
        .refTag("string")
        .build());
    
    git_repository_branch_resource = azuredevops.GitRepositoryBranch("gitRepositoryBranchResource",
        repository_id="string",
        name="string",
        ref_branch="string",
        ref_commit_id="string",
        ref_tag="string")
    
    const gitRepositoryBranchResource = new azuredevops.GitRepositoryBranch("gitRepositoryBranchResource", {
        repositoryId: "string",
        name: "string",
        refBranch: "string",
        refCommitId: "string",
        refTag: "string",
    });
    
    type: azuredevops:GitRepositoryBranch
    properties:
        name: string
        refBranch: string
        refCommitId: string
        refTag: string
        repositoryId: string
    

    GitRepositoryBranch 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 GitRepositoryBranch resource accepts the following input properties:

    RepositoryId string
    The ID of the repository the branch is created against.
    Name string
    The name of the branch in short format not prefixed with refs/heads/.
    RefBranch string
    The reference to the source branch to create the branch from, in <name> or refs/heads/<name> format. Conflict with ref_tag, ref_commit_id.
    RefCommitId string
    The commit object ID to create the branch from. Conflict with ref_branch, ref_tag.
    RefTag string
    The reference to the tag to create the branch from, in <name> or refs/tags/<name> format. Conflict with ref_branch, ref_commit_id.
    RepositoryId string
    The ID of the repository the branch is created against.
    Name string
    The name of the branch in short format not prefixed with refs/heads/.
    RefBranch string
    The reference to the source branch to create the branch from, in <name> or refs/heads/<name> format. Conflict with ref_tag, ref_commit_id.
    RefCommitId string
    The commit object ID to create the branch from. Conflict with ref_branch, ref_tag.
    RefTag string
    The reference to the tag to create the branch from, in <name> or refs/tags/<name> format. Conflict with ref_branch, ref_commit_id.
    repositoryId String
    The ID of the repository the branch is created against.
    name String
    The name of the branch in short format not prefixed with refs/heads/.
    refBranch String
    The reference to the source branch to create the branch from, in <name> or refs/heads/<name> format. Conflict with ref_tag, ref_commit_id.
    refCommitId String
    The commit object ID to create the branch from. Conflict with ref_branch, ref_tag.
    refTag String
    The reference to the tag to create the branch from, in <name> or refs/tags/<name> format. Conflict with ref_branch, ref_commit_id.
    repositoryId string
    The ID of the repository the branch is created against.
    name string
    The name of the branch in short format not prefixed with refs/heads/.
    refBranch string
    The reference to the source branch to create the branch from, in <name> or refs/heads/<name> format. Conflict with ref_tag, ref_commit_id.
    refCommitId string
    The commit object ID to create the branch from. Conflict with ref_branch, ref_tag.
    refTag string
    The reference to the tag to create the branch from, in <name> or refs/tags/<name> format. Conflict with ref_branch, ref_commit_id.
    repository_id str
    The ID of the repository the branch is created against.
    name str
    The name of the branch in short format not prefixed with refs/heads/.
    ref_branch str
    The reference to the source branch to create the branch from, in <name> or refs/heads/<name> format. Conflict with ref_tag, ref_commit_id.
    ref_commit_id str
    The commit object ID to create the branch from. Conflict with ref_branch, ref_tag.
    ref_tag str
    The reference to the tag to create the branch from, in <name> or refs/tags/<name> format. Conflict with ref_branch, ref_commit_id.
    repositoryId String
    The ID of the repository the branch is created against.
    name String
    The name of the branch in short format not prefixed with refs/heads/.
    refBranch String
    The reference to the source branch to create the branch from, in <name> or refs/heads/<name> format. Conflict with ref_tag, ref_commit_id.
    refCommitId String
    The commit object ID to create the branch from. Conflict with ref_branch, ref_tag.
    refTag String
    The reference to the tag to create the branch from, in <name> or refs/tags/<name> format. Conflict with ref_branch, ref_commit_id.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the GitRepositoryBranch resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    LastCommitId string
    The commit object ID of last commit on the branch.
    Id string
    The provider-assigned unique ID for this managed resource.
    LastCommitId string
    The commit object ID of last commit on the branch.
    id String
    The provider-assigned unique ID for this managed resource.
    lastCommitId String
    The commit object ID of last commit on the branch.
    id string
    The provider-assigned unique ID for this managed resource.
    lastCommitId string
    The commit object ID of last commit on the branch.
    id str
    The provider-assigned unique ID for this managed resource.
    last_commit_id str
    The commit object ID of last commit on the branch.
    id String
    The provider-assigned unique ID for this managed resource.
    lastCommitId String
    The commit object ID of last commit on the branch.

    Look up Existing GitRepositoryBranch Resource

    Get an existing GitRepositoryBranch 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?: GitRepositoryBranchState, opts?: CustomResourceOptions): GitRepositoryBranch
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            last_commit_id: Optional[str] = None,
            name: Optional[str] = None,
            ref_branch: Optional[str] = None,
            ref_commit_id: Optional[str] = None,
            ref_tag: Optional[str] = None,
            repository_id: Optional[str] = None) -> GitRepositoryBranch
    func GetGitRepositoryBranch(ctx *Context, name string, id IDInput, state *GitRepositoryBranchState, opts ...ResourceOption) (*GitRepositoryBranch, error)
    public static GitRepositoryBranch Get(string name, Input<string> id, GitRepositoryBranchState? state, CustomResourceOptions? opts = null)
    public static GitRepositoryBranch get(String name, Output<String> id, GitRepositoryBranchState 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:
    LastCommitId string
    The commit object ID of last commit on the branch.
    Name string
    The name of the branch in short format not prefixed with refs/heads/.
    RefBranch string
    The reference to the source branch to create the branch from, in <name> or refs/heads/<name> format. Conflict with ref_tag, ref_commit_id.
    RefCommitId string
    The commit object ID to create the branch from. Conflict with ref_branch, ref_tag.
    RefTag string
    The reference to the tag to create the branch from, in <name> or refs/tags/<name> format. Conflict with ref_branch, ref_commit_id.
    RepositoryId string
    The ID of the repository the branch is created against.
    LastCommitId string
    The commit object ID of last commit on the branch.
    Name string
    The name of the branch in short format not prefixed with refs/heads/.
    RefBranch string
    The reference to the source branch to create the branch from, in <name> or refs/heads/<name> format. Conflict with ref_tag, ref_commit_id.
    RefCommitId string
    The commit object ID to create the branch from. Conflict with ref_branch, ref_tag.
    RefTag string
    The reference to the tag to create the branch from, in <name> or refs/tags/<name> format. Conflict with ref_branch, ref_commit_id.
    RepositoryId string
    The ID of the repository the branch is created against.
    lastCommitId String
    The commit object ID of last commit on the branch.
    name String
    The name of the branch in short format not prefixed with refs/heads/.
    refBranch String
    The reference to the source branch to create the branch from, in <name> or refs/heads/<name> format. Conflict with ref_tag, ref_commit_id.
    refCommitId String
    The commit object ID to create the branch from. Conflict with ref_branch, ref_tag.
    refTag String
    The reference to the tag to create the branch from, in <name> or refs/tags/<name> format. Conflict with ref_branch, ref_commit_id.
    repositoryId String
    The ID of the repository the branch is created against.
    lastCommitId string
    The commit object ID of last commit on the branch.
    name string
    The name of the branch in short format not prefixed with refs/heads/.
    refBranch string
    The reference to the source branch to create the branch from, in <name> or refs/heads/<name> format. Conflict with ref_tag, ref_commit_id.
    refCommitId string
    The commit object ID to create the branch from. Conflict with ref_branch, ref_tag.
    refTag string
    The reference to the tag to create the branch from, in <name> or refs/tags/<name> format. Conflict with ref_branch, ref_commit_id.
    repositoryId string
    The ID of the repository the branch is created against.
    last_commit_id str
    The commit object ID of last commit on the branch.
    name str
    The name of the branch in short format not prefixed with refs/heads/.
    ref_branch str
    The reference to the source branch to create the branch from, in <name> or refs/heads/<name> format. Conflict with ref_tag, ref_commit_id.
    ref_commit_id str
    The commit object ID to create the branch from. Conflict with ref_branch, ref_tag.
    ref_tag str
    The reference to the tag to create the branch from, in <name> or refs/tags/<name> format. Conflict with ref_branch, ref_commit_id.
    repository_id str
    The ID of the repository the branch is created against.
    lastCommitId String
    The commit object ID of last commit on the branch.
    name String
    The name of the branch in short format not prefixed with refs/heads/.
    refBranch String
    The reference to the source branch to create the branch from, in <name> or refs/heads/<name> format. Conflict with ref_tag, ref_commit_id.
    refCommitId String
    The commit object ID to create the branch from. Conflict with ref_branch, ref_tag.
    refTag String
    The reference to the tag to create the branch from, in <name> or refs/tags/<name> format. Conflict with ref_branch, ref_commit_id.
    repositoryId String
    The ID of the repository the branch is created against.

    Package Details

    Repository
    Azure DevOps pulumi/pulumi-azuredevops
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the azuredevops Terraform Provider.
    azuredevops logo
    Azure DevOps v3.1.1 published on Monday, May 20, 2024 by Pulumi