gitlab logo
GitLab v4.9.0, Oct 24 22

gitlab.Branch

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

Upstream API: GitLab REST API docs

Example Usage

using System.Collections.Generic;
using Pulumi;
using GitLab = Pulumi.GitLab;

return await Deployment.RunAsync(() => 
{
    // Create a project for the branch to use
    var exampleProject = new GitLab.Project("exampleProject", new()
    {
        Description = "An example project",
        NamespaceId = gitlab_group.Example.Id,
    });

    var exampleBranch = new GitLab.Branch("exampleBranch", new()
    {
        Ref = "main",
        Project = exampleProject.Id,
    });

});
package main

import (
	"github.com/pulumi/pulumi-gitlab/sdk/v4/go/gitlab"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		exampleProject, err := gitlab.NewProject(ctx, "exampleProject", &gitlab.ProjectArgs{
			Description: pulumi.String("An example project"),
			NamespaceId: pulumi.Any(gitlab_group.Example.Id),
		})
		if err != nil {
			return err
		}
		_, err = gitlab.NewBranch(ctx, "exampleBranch", &gitlab.BranchArgs{
			Ref:     pulumi.String("main"),
			Project: exampleProject.ID(),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
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) {
        var exampleProject = new Project("exampleProject", ProjectArgs.builder()        
            .description("An example project")
            .namespaceId(gitlab_group.example().id())
            .build());

        var exampleBranch = new Branch("exampleBranch", BranchArgs.builder()        
            .ref("main")
            .project(exampleProject.id())
            .build());

    }
}
import pulumi
import pulumi_gitlab as gitlab

# Create a project for the branch to use
example_project = gitlab.Project("exampleProject",
    description="An example project",
    namespace_id=gitlab_group["example"]["id"])
example_branch = gitlab.Branch("exampleBranch",
    ref="main",
    project=example_project.id)
import * as pulumi from "@pulumi/pulumi";
import * as gitlab from "@pulumi/gitlab";

// Create a project for the branch to use
const exampleProject = new gitlab.Project("exampleProject", {
    description: "An example project",
    namespaceId: gitlab_group.example.id,
});
const exampleBranch = new gitlab.Branch("exampleBranch", {
    ref: "main",
    project: exampleProject.id,
});
resources:
  # Create a project for the branch to use
  exampleProject:
    type: gitlab:Project
    properties:
      description: An example project
      namespaceId: ${gitlab_group.example.id}
  exampleBranch:
    type: gitlab:Branch
    properties:
      ref: main
      project: ${exampleProject.id}

Create Branch Resource

new Branch(name: string, args: BranchArgs, opts?: CustomResourceOptions);
@overload
def Branch(resource_name: str,
           opts: Optional[ResourceOptions] = None,
           name: Optional[str] = None,
           project: Optional[str] = None,
           ref: Optional[str] = None)
@overload
def Branch(resource_name: str,
           args: BranchArgs,
           opts: Optional[ResourceOptions] = 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.

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.

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.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 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<BranchCommitArgs>

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 BranchCommitArgs[]

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

AuthorEmail string
AuthorName string
AuthoredDate string
CommittedDate string
CommitterEmail string
CommitterName string
Id string

The ID of this resource.

Message string
ParentIds List<string>
ShortId string
Title string
AuthorEmail string
AuthorName string
AuthoredDate string
CommittedDate string
CommitterEmail string
CommitterName string
Id string

The ID of this resource.

Message string
ParentIds []string
ShortId string
Title string
authorEmail String
authorName String
authoredDate String
committedDate String
committerEmail String
committerName String
id String

The ID of this resource.

message String
parentIds List<String>
shortId String
title String
authorEmail string
authorName string
authoredDate string
committedDate string
committerEmail string
committerName string
id string

The ID of this resource.

message string
parentIds string[]
shortId string
title string
author_email str
author_name str
authored_date str
committed_date str
committer_email str
committer_name str
id str

The ID of this resource.

message str
parent_ids Sequence[str]
short_id str
title str
authorEmail String
authorName String
authoredDate String
committedDate String
committerEmail String
committerName String
id String

The ID of this resource.

message String
parentIds List<String>
shortId String
title String

Import

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

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

Package Details

Repository
GitLab pulumi/pulumi-gitlab
License
Apache-2.0
Notes

This Pulumi package is based on the gitlab Terraform Provider.