gitlab.Branch
Explore with Pulumi AI
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
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The Branch resource accepts the following input properties:
Outputs
All input properties are implicitly available as output properties. Additionally, the Branch resource produces the following output properties:
- Can
Push bool - Bool, true if you can push to the branch.
- Commits
List<Pulumi.
Git Lab. Outputs. Branch Commit> - The commit associated with the branch ref.
- Default bool
- Bool, true if branch is the default branch for the project.
- Developer
Can boolMerge - Bool, true if developer level access allows to merge branch.
- Developer
Can boolPush - 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.
- Web
Url string - The url of the created branch (https).
- Can
Push bool - Bool, true if you can push to the branch.
- Commits
[]Branch
Commit - The commit associated with the branch ref.
- Default bool
- Bool, true if branch is the default branch for the project.
- Developer
Can boolMerge - Bool, true if developer level access allows to merge branch.
- Developer
Can boolPush - 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.
- Web
Url string - The url of the created branch (https).
- can
Push Boolean - Bool, true if you can push to the branch.
- commits
List<Branch
Commit> - The commit associated with the branch ref.
- default_ Boolean
- Bool, true if branch is the default branch for the project.
- developer
Can BooleanMerge - Bool, true if developer level access allows to merge branch.
- developer
Can BooleanPush - 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.
- web
Url String - The url of the created branch (https).
- can
Push boolean - Bool, true if you can push to the branch.
- commits
Branch
Commit[] - The commit associated with the branch ref.
- default boolean
- Bool, true if branch is the default branch for the project.
- developer
Can booleanMerge - Bool, true if developer level access allows to merge branch.
- developer
Can booleanPush - 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.
- web
Url string - The url of the created branch (https).
- can_
push bool - Bool, true if you can push to the branch.
- commits
Sequence[Branch
Commit] - The commit associated with the branch ref.
- default bool
- Bool, true if branch is the default branch for the project.
- developer_
can_ boolmerge - Bool, true if developer level access allows to merge branch.
- developer_
can_ boolpush - 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).
- can
Push 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.
- developer
Can BooleanMerge - Bool, true if developer level access allows to merge branch.
- developer
Can BooleanPush - 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.
- web
Url 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.
- Can
Push bool - Bool, true if you can push to the branch.
- Commits
List<Pulumi.
Git Lab. Inputs. Branch Commit> - The commit associated with the branch ref.
- Default bool
- Bool, true if branch is the default branch for the project.
- Developer
Can boolMerge - Bool, true if developer level access allows to merge branch.
- Developer
Can boolPush - 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.
- Web
Url string - The url of the created branch (https).
- Can
Push bool - Bool, true if you can push to the branch.
- Commits
[]Branch
Commit Args - The commit associated with the branch ref.
- Default bool
- Bool, true if branch is the default branch for the project.
- Developer
Can boolMerge - Bool, true if developer level access allows to merge branch.
- Developer
Can boolPush - 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.
- Web
Url string - The url of the created branch (https).
- can
Push Boolean - Bool, true if you can push to the branch.
- commits
List<Branch
Commit> - The commit associated with the branch ref.
- default_ Boolean
- Bool, true if branch is the default branch for the project.
- developer
Can BooleanMerge - Bool, true if developer level access allows to merge branch.
- developer
Can BooleanPush - 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.
- web
Url String - The url of the created branch (https).
- can
Push boolean - Bool, true if you can push to the branch.
- commits
Branch
Commit[] - The commit associated with the branch ref.
- default boolean
- Bool, true if branch is the default branch for the project.
- developer
Can booleanMerge - Bool, true if developer level access allows to merge branch.
- developer
Can booleanPush - 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.
- web
Url string - The url of the created branch (https).
- can_
push bool - Bool, true if you can push to the branch.
- commits
Sequence[Branch
Commit Args] - The commit associated with the branch ref.
- default bool
- Bool, true if branch is the default branch for the project.
- developer_
can_ boolmerge - Bool, true if developer level access allows to merge branch.
- developer_
can_ boolpush - 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).
- can
Push 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.
- developer
Can BooleanMerge - Bool, true if developer level access allows to merge branch.
- developer
Can BooleanPush - 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.
- web
Url String - The url of the created branch (https).
Supporting Types
BranchCommit, BranchCommitArgs
- string
- The email of the author.
- string
- The name of the author.
- string
- The date which the commit was authored (format: yyyy-MM-ddTHH:mm:ssZ).
- Committed
Date string - The date at which the commit was pushed (format: yyyy-MM-ddTHH:mm:ssZ).
- Committer
Email string - The email of the user that committed.
- Committer
Name string - The name of the user that committed.
- Id string
- The unique id assigned to the commit by Gitlab.
- Message string
- The commit message
- Parent
Ids List<string> - The id of the parents of the commit
- Short
Id string - The short id assigned to the commit by Gitlab.
- Title string
- The title of the commit
- string
- The email of the author.
- string
- The name of the author.
- string
- The date which the commit was authored (format: yyyy-MM-ddTHH:mm:ssZ).
- Committed
Date string - The date at which the commit was pushed (format: yyyy-MM-ddTHH:mm:ssZ).
- Committer
Email string - The email of the user that committed.
- Committer
Name string - The name of the user that committed.
- Id string
- The unique id assigned to the commit by Gitlab.
- Message string
- The commit message
- Parent
Ids []string - The id of the parents of the commit
- Short
Id string - The short id assigned to the commit by Gitlab.
- Title string
- The title of the commit
- String
- The email of the author.
- String
- The name of the author.
- String
- The date which the commit was authored (format: yyyy-MM-ddTHH:mm:ssZ).
- committed
Date String - The date at which the commit was pushed (format: yyyy-MM-ddTHH:mm:ssZ).
- committer
Email String - The email of the user that committed.
- committer
Name String - The name of the user that committed.
- id String
- The unique id assigned to the commit by Gitlab.
- message String
- The commit message
- parent
Ids List<String> - The id of the parents of the commit
- short
Id String - The short id assigned to the commit by Gitlab.
- title String
- The title of the commit
- string
- The email of the author.
- string
- The name of the author.
- string
- The date which the commit was authored (format: yyyy-MM-ddTHH:mm:ssZ).
- committed
Date string - The date at which the commit was pushed (format: yyyy-MM-ddTHH:mm:ssZ).
- committer
Email string - The email of the user that committed.
- committer
Name string - The name of the user that committed.
- id string
- The unique id assigned to the commit by Gitlab.
- message string
- The commit message
- parent
Ids string[] - The id of the parents of the commit
- short
Id string - The short id assigned to the commit by Gitlab.
- title string
- The title of the commit
- str
- The email of the author.
- str
- The name of the author.
- 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
- String
- The email of the author.
- String
- The name of the author.
- String
- The date which the commit was authored (format: yyyy-MM-ddTHH:mm:ssZ).
- committed
Date String - The date at which the commit was pushed (format: yyyy-MM-ddTHH:mm:ssZ).
- committer
Email String - The email of the user that committed.
- committer
Name String - The name of the user that committed.
- id String
- The unique id assigned to the commit by Gitlab.
- message String
- The commit message
- parent
Ids List<String> - The id of the parents of the commit
- short
Id String - The short id assigned to the commit by Gitlab.
- title String
- The title of the commit
Import
Starting in Terraform v1.5.0 you can use an import block to import gitlab_branch
. For example:
terraform
import {
to = gitlab_branch.example
id = “see CLI command below for ID”
}
Import using the CLI is supported using the following syntax:
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.