1. Packages
  2. GitLab
  3. API Docs
  4. Branch
GitLab v8.1.0 published on Friday, Jun 21, 2024 by Pulumi

gitlab.Branch

Explore with Pulumi AI

gitlab logo
GitLab v8.1.0 published on Friday, Jun 21, 2024 by Pulumi

    The gitlab.Branch resource allows to manage the lifecycle of a repository branch.

    Upstream API: GitLab REST API docs

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as gitlab from "@pulumi/gitlab";
    
    // Create a project for the branch to use
    const example = new gitlab.Project("example", {
        name: "example",
        description: "An example project",
        namespaceId: exampleGitlabGroup.id,
    });
    const exampleBranch = new gitlab.Branch("example", {
        name: "example",
        ref: "main",
        project: example.id,
    });
    
    import pulumi
    import pulumi_gitlab as gitlab
    
    # Create a project for the branch to use
    example = gitlab.Project("example",
        name="example",
        description="An example project",
        namespace_id=example_gitlab_group["id"])
    example_branch = gitlab.Branch("example",
        name="example",
        ref="main",
        project=example.id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-gitlab/sdk/v8/go/gitlab"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		// Create a project for the branch to use
    		example, err := gitlab.NewProject(ctx, "example", &gitlab.ProjectArgs{
    			Name:        pulumi.String("example"),
    			Description: pulumi.String("An example project"),
    			NamespaceId: pulumi.Any(exampleGitlabGroup.Id),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = gitlab.NewBranch(ctx, "example", &gitlab.BranchArgs{
    			Name:    pulumi.String("example"),
    			Ref:     pulumi.String("main"),
    			Project: example.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using GitLab = Pulumi.GitLab;
    
    return await Deployment.RunAsync(() => 
    {
        // Create a project for the branch to use
        var example = new GitLab.Project("example", new()
        {
            Name = "example",
            Description = "An example project",
            NamespaceId = exampleGitlabGroup.Id,
        });
    
        var exampleBranch = new GitLab.Branch("example", new()
        {
            Name = "example",
            Ref = "main",
            Project = example.Id,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.gitlab.Project;
    import com.pulumi.gitlab.ProjectArgs;
    import com.pulumi.gitlab.Branch;
    import com.pulumi.gitlab.BranchArgs;
    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) {
            // Create a project for the branch to use
            var example = new Project("example", ProjectArgs.builder()
                .name("example")
                .description("An example project")
                .namespaceId(exampleGitlabGroup.id())
                .build());
    
            var exampleBranch = new Branch("exampleBranch", BranchArgs.builder()
                .name("example")
                .ref("main")
                .project(example.id())
                .build());
    
        }
    }
    
    resources:
      # Create a project for the branch to use
      example:
        type: gitlab:Project
        properties:
          name: example
          description: An example project
          namespaceId: ${exampleGitlabGroup.id}
      exampleBranch:
        type: gitlab:Branch
        name: example
        properties:
          name: example
          ref: main
          project: ${example.id}
    

    Create Branch Resource

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

    Constructor syntax

    new Branch(name: string, args: BranchArgs, opts?: CustomResourceOptions);
    @overload
    def Branch(resource_name: str,
               args: BranchArgs,
               opts: Optional[ResourceOptions] = None)
    
    @overload
    def Branch(resource_name: str,
               opts: Optional[ResourceOptions] = None,
               project: Optional[str] = None,
               ref: Optional[str] = None,
               name: Optional[str] = None)
    func NewBranch(ctx *Context, name string, args BranchArgs, opts ...ResourceOption) (*Branch, error)
    public Branch(string name, BranchArgs args, CustomResourceOptions? opts = null)
    public Branch(String name, BranchArgs args)
    public Branch(String name, BranchArgs args, CustomResourceOptions options)
    
    type: gitlab:Branch
    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 BranchArgs
    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 BranchArgs
    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 BranchArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args BranchArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args BranchArgs
    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 branchResource = new GitLab.Branch("branchResource", new()
    {
        Project = "string",
        Ref = "string",
        Name = "string",
    });
    
    example, err := gitlab.NewBranch(ctx, "branchResource", &gitlab.BranchArgs{
    	Project: pulumi.String("string"),
    	Ref:     pulumi.String("string"),
    	Name:    pulumi.String("string"),
    })
    
    var branchResource = new Branch("branchResource", BranchArgs.builder()
        .project("string")
        .ref("string")
        .name("string")
        .build());
    
    branch_resource = gitlab.Branch("branchResource",
        project="string",
        ref="string",
        name="string")
    
    const branchResource = new gitlab.Branch("branchResource", {
        project: "string",
        ref: "string",
        name: "string",
    });
    
    type: gitlab:Branch
    properties:
        name: string
        project: string
        ref: string
    

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

    Project string
    The ID or full path of the project which the branch is created against.
    Ref string
    The ref which the branch is created from.
    Name string
    The name for this branch.
    Project string
    The ID or full path of the project which the branch is created against.
    Ref string
    The ref which the branch is created from.
    Name string
    The name for this branch.
    project String
    The ID or full path of the project which the branch is created against.
    ref String
    The ref which the branch is created from.
    name String
    The name for this branch.
    project string
    The ID or full path of the project which the branch is created against.
    ref string
    The ref which the branch is created from.
    name string
    The name for this branch.
    project str
    The ID or full path of the project which the branch is created against.
    ref str
    The ref which the branch is created from.
    name str
    The name for this branch.
    project String
    The ID or full path of the project which the branch is created against.
    ref String
    The ref which the branch is created from.
    name String
    The name for this branch.

    Outputs

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

    CanPush bool
    Bool, true if you can push to the branch.
    Commits List<Pulumi.GitLab.Outputs.BranchCommit>
    The commit associated with the branch ref.
    Default bool
    Bool, true if branch is the default branch for the project.
    DeveloperCanMerge bool
    Bool, true if developer level access allows to merge branch.
    DeveloperCanPush bool
    Bool, true if developer level access allows git push.
    Id string
    The provider-assigned unique ID for this managed resource.
    Merged bool
    Bool, true if the branch has been merged into it's parent.
    Protected bool
    Bool, true if branch has branch protection.
    WebUrl string
    The url of the created branch (https).
    CanPush bool
    Bool, true if you can push to the branch.
    Commits []BranchCommit
    The commit associated with the branch ref.
    Default bool
    Bool, true if branch is the default branch for the project.
    DeveloperCanMerge bool
    Bool, true if developer level access allows to merge branch.
    DeveloperCanPush bool
    Bool, true if developer level access allows git push.
    Id string
    The provider-assigned unique ID for this managed resource.
    Merged bool
    Bool, true if the branch has been merged into it's parent.
    Protected bool
    Bool, true if branch has branch protection.
    WebUrl string
    The url of the created branch (https).
    canPush Boolean
    Bool, true if you can push to the branch.
    commits List<BranchCommit>
    The commit associated with the branch ref.
    default_ Boolean
    Bool, true if branch is the default branch for the project.
    developerCanMerge Boolean
    Bool, true if developer level access allows to merge branch.
    developerCanPush Boolean
    Bool, true if developer level access allows git push.
    id String
    The provider-assigned unique ID for this managed resource.
    merged Boolean
    Bool, true if the branch has been merged into it's parent.
    protected_ Boolean
    Bool, true if branch has branch protection.
    webUrl String
    The url of the created branch (https).
    canPush boolean
    Bool, true if you can push to the branch.
    commits BranchCommit[]
    The commit associated with the branch ref.
    default boolean
    Bool, true if branch is the default branch for the project.
    developerCanMerge boolean
    Bool, true if developer level access allows to merge branch.
    developerCanPush boolean
    Bool, true if developer level access allows git push.
    id string
    The provider-assigned unique ID for this managed resource.
    merged boolean
    Bool, true if the branch has been merged into it's parent.
    protected boolean
    Bool, true if branch has branch protection.
    webUrl string
    The url of the created branch (https).
    can_push bool
    Bool, true if you can push to the branch.
    commits Sequence[BranchCommit]
    The commit associated with the branch ref.
    default bool
    Bool, true if branch is the default branch for the project.
    developer_can_merge bool
    Bool, true if developer level access allows to merge branch.
    developer_can_push bool
    Bool, true if developer level access allows git push.
    id str
    The provider-assigned unique ID for this managed resource.
    merged bool
    Bool, true if the branch has been merged into it's parent.
    protected bool
    Bool, true if branch has branch protection.
    web_url str
    The url of the created branch (https).
    canPush Boolean
    Bool, true if you can push to the branch.
    commits List<Property Map>
    The commit associated with the branch ref.
    default Boolean
    Bool, true if branch is the default branch for the project.
    developerCanMerge Boolean
    Bool, true if developer level access allows to merge branch.
    developerCanPush Boolean
    Bool, true if developer level access allows git push.
    id String
    The provider-assigned unique ID for this managed resource.
    merged Boolean
    Bool, true if the branch has been merged into it's parent.
    protected Boolean
    Bool, true if branch has branch protection.
    webUrl String
    The url of the created branch (https).

    Look up Existing Branch Resource

    Get an existing Branch 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?: BranchState, opts?: CustomResourceOptions): Branch
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            can_push: Optional[bool] = None,
            commits: Optional[Sequence[BranchCommitArgs]] = None,
            default: Optional[bool] = None,
            developer_can_merge: Optional[bool] = None,
            developer_can_push: Optional[bool] = None,
            merged: Optional[bool] = None,
            name: Optional[str] = None,
            project: Optional[str] = None,
            protected: Optional[bool] = None,
            ref: Optional[str] = None,
            web_url: Optional[str] = None) -> Branch
    func GetBranch(ctx *Context, name string, id IDInput, state *BranchState, opts ...ResourceOption) (*Branch, error)
    public static Branch Get(string name, Input<string> id, BranchState? state, CustomResourceOptions? opts = null)
    public static Branch get(String name, Output<String> id, BranchState 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:
    CanPush bool
    Bool, true if you can push to the branch.
    Commits List<Pulumi.GitLab.Inputs.BranchCommit>
    The commit associated with the branch ref.
    Default bool
    Bool, true if branch is the default branch for the project.
    DeveloperCanMerge bool
    Bool, true if developer level access allows to merge branch.
    DeveloperCanPush bool
    Bool, true if developer level access allows git push.
    Merged bool
    Bool, true if the branch has been merged into it's parent.
    Name string
    The name for this branch.
    Project string
    The ID or full path of the project which the branch is created against.
    Protected bool
    Bool, true if branch has branch protection.
    Ref string
    The ref which the branch is created from.
    WebUrl string
    The url of the created branch (https).
    CanPush bool
    Bool, true if you can push to the branch.
    Commits []BranchCommitArgs
    The commit associated with the branch ref.
    Default bool
    Bool, true if branch is the default branch for the project.
    DeveloperCanMerge bool
    Bool, true if developer level access allows to merge branch.
    DeveloperCanPush bool
    Bool, true if developer level access allows git push.
    Merged bool
    Bool, true if the branch has been merged into it's parent.
    Name string
    The name for this branch.
    Project string
    The ID or full path of the project which the branch is created against.
    Protected bool
    Bool, true if branch has branch protection.
    Ref string
    The ref which the branch is created from.
    WebUrl string
    The url of the created branch (https).
    canPush Boolean
    Bool, true if you can push to the branch.
    commits List<BranchCommit>
    The commit associated with the branch ref.
    default_ Boolean
    Bool, true if branch is the default branch for the project.
    developerCanMerge Boolean
    Bool, true if developer level access allows to merge branch.
    developerCanPush Boolean
    Bool, true if developer level access allows git push.
    merged Boolean
    Bool, true if the branch has been merged into it's parent.
    name String
    The name for this branch.
    project String
    The ID or full path of the project which the branch is created against.
    protected_ Boolean
    Bool, true if branch has branch protection.
    ref String
    The ref which the branch is created from.
    webUrl String
    The url of the created branch (https).
    canPush boolean
    Bool, true if you can push to the branch.
    commits BranchCommit[]
    The commit associated with the branch ref.
    default boolean
    Bool, true if branch is the default branch for the project.
    developerCanMerge boolean
    Bool, true if developer level access allows to merge branch.
    developerCanPush boolean
    Bool, true if developer level access allows git push.
    merged boolean
    Bool, true if the branch has been merged into it's parent.
    name string
    The name for this branch.
    project string
    The ID or full path of the project which the branch is created against.
    protected boolean
    Bool, true if branch has branch protection.
    ref string
    The ref which the branch is created from.
    webUrl string
    The url of the created branch (https).
    can_push bool
    Bool, true if you can push to the branch.
    commits Sequence[BranchCommitArgs]
    The commit associated with the branch ref.
    default bool
    Bool, true if branch is the default branch for the project.
    developer_can_merge bool
    Bool, true if developer level access allows to merge branch.
    developer_can_push bool
    Bool, true if developer level access allows git push.
    merged bool
    Bool, true if the branch has been merged into it's parent.
    name str
    The name for this branch.
    project str
    The ID or full path of the project which the branch is created against.
    protected bool
    Bool, true if branch has branch protection.
    ref str
    The ref which the branch is created from.
    web_url str
    The url of the created branch (https).
    canPush Boolean
    Bool, true if you can push to the branch.
    commits List<Property Map>
    The commit associated with the branch ref.
    default Boolean
    Bool, true if branch is the default branch for the project.
    developerCanMerge Boolean
    Bool, true if developer level access allows to merge branch.
    developerCanPush Boolean
    Bool, true if developer level access allows git push.
    merged Boolean
    Bool, true if the branch has been merged into it's parent.
    name String
    The name for this branch.
    project String
    The ID or full path of the project which the branch is created against.
    protected Boolean
    Bool, true if branch has branch protection.
    ref String
    The ref which the branch is created from.
    webUrl String
    The url of the created branch (https).

    Supporting Types

    BranchCommit, BranchCommitArgs

    AuthorEmail string
    The email of the author.
    AuthorName string
    The name of the author.
    AuthoredDate string
    The date which the commit was authored (format: yyyy-MM-ddTHH:mm:ssZ).
    CommittedDate string
    The date at which the commit was pushed (format: yyyy-MM-ddTHH:mm:ssZ).
    CommitterEmail string
    The email of the user that committed.
    CommitterName string
    The name of the user that committed.
    Id string
    The unique id assigned to the commit by Gitlab.
    Message string
    The commit message
    ParentIds List<string>
    The id of the parents of the commit
    ShortId string
    The short id assigned to the commit by Gitlab.
    Title string
    The title of the commit
    AuthorEmail string
    The email of the author.
    AuthorName string
    The name of the author.
    AuthoredDate string
    The date which the commit was authored (format: yyyy-MM-ddTHH:mm:ssZ).
    CommittedDate string
    The date at which the commit was pushed (format: yyyy-MM-ddTHH:mm:ssZ).
    CommitterEmail string
    The email of the user that committed.
    CommitterName string
    The name of the user that committed.
    Id string
    The unique id assigned to the commit by Gitlab.
    Message string
    The commit message
    ParentIds []string
    The id of the parents of the commit
    ShortId string
    The short id assigned to the commit by Gitlab.
    Title string
    The title of the commit
    authorEmail String
    The email of the author.
    authorName String
    The name of the author.
    authoredDate String
    The date which the commit was authored (format: yyyy-MM-ddTHH:mm:ssZ).
    committedDate String
    The date at which the commit was pushed (format: yyyy-MM-ddTHH:mm:ssZ).
    committerEmail String
    The email of the user that committed.
    committerName String
    The name of the user that committed.
    id String
    The unique id assigned to the commit by Gitlab.
    message String
    The commit message
    parentIds List<String>
    The id of the parents of the commit
    shortId String
    The short id assigned to the commit by Gitlab.
    title String
    The title of the commit
    authorEmail string
    The email of the author.
    authorName string
    The name of the author.
    authoredDate string
    The date which the commit was authored (format: yyyy-MM-ddTHH:mm:ssZ).
    committedDate string
    The date at which the commit was pushed (format: yyyy-MM-ddTHH:mm:ssZ).
    committerEmail string
    The email of the user that committed.
    committerName string
    The name of the user that committed.
    id string
    The unique id assigned to the commit by Gitlab.
    message string
    The commit message
    parentIds string[]
    The id of the parents of the commit
    shortId string
    The short id assigned to the commit by Gitlab.
    title string
    The title of the commit
    author_email str
    The email of the author.
    author_name str
    The name of the author.
    authored_date str
    The date which the commit was authored (format: yyyy-MM-ddTHH:mm:ssZ).
    committed_date str
    The date at which the commit was pushed (format: yyyy-MM-ddTHH:mm:ssZ).
    committer_email str
    The email of the user that committed.
    committer_name str
    The name of the user that committed.
    id str
    The unique id assigned to the commit by Gitlab.
    message str
    The commit message
    parent_ids Sequence[str]
    The id of the parents of the commit
    short_id str
    The short id assigned to the commit by Gitlab.
    title str
    The title of the commit
    authorEmail String
    The email of the author.
    authorName String
    The name of the author.
    authoredDate String
    The date which the commit was authored (format: yyyy-MM-ddTHH:mm:ssZ).
    committedDate String
    The date at which the commit was pushed (format: yyyy-MM-ddTHH:mm:ssZ).
    committerEmail String
    The email of the user that committed.
    committerName String
    The name of the user that committed.
    id String
    The unique id assigned to the commit by Gitlab.
    message String
    The commit message
    parentIds List<String>
    The id of the parents of the commit
    shortId String
    The short id assigned to the commit by Gitlab.
    title String
    The title of the commit

    Import

    Gitlab branches can be imported with a key composed of <project_id>:<branch_name>, e.g.

    $ pulumi import gitlab:index/branch:Branch example "12345:develop"
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    GitLab pulumi/pulumi-gitlab
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the gitlab Terraform Provider.
    gitlab logo
    GitLab v8.1.0 published on Friday, Jun 21, 2024 by Pulumi