Branch

class Branch : KotlinCustomResource

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 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,
});
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)
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 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/v6/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
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) {
// Create a project for the branch to use
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());
}
}
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}

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"

Properties

Link copied to clipboard
val canPush: Output<Boolean>

Bool, true if you can push to the branch.

Link copied to clipboard
val commits: Output<List<BranchCommit>>

The commit associated with the branch ref.

Link copied to clipboard
val default: Output<Boolean>

Bool, true if branch is the default branch for the project.

Link copied to clipboard

Bool, true if developer level access allows to merge branch.

Link copied to clipboard

Bool, true if developer level access allows git push.

Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val merged: Output<Boolean>

Bool, true if the branch has been merged into it's parent.

Link copied to clipboard
val name: Output<String>

The name for this branch.

Link copied to clipboard
val project: Output<String>

The ID or full path of the project which the branch is created against.

Link copied to clipboard
val protected: Output<Boolean>

Bool, true if branch has branch protection.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val ref: Output<String>

The ref which the branch is created from.

Link copied to clipboard
val urn: Output<String>
Link copied to clipboard
val webUrl: Output<String>

The url of the created branch (https).