BranchProtection

class BranchProtection : KotlinCustomResource

Example Usage

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gitlab.BranchProtection;
import com.pulumi.gitlab.BranchProtectionArgs;
import com.pulumi.gitlab.inputs.BranchProtectionAllowedToPushArgs;
import com.pulumi.gitlab.inputs.BranchProtectionAllowedToMergeArgs;
import com.pulumi.gitlab.inputs.BranchProtectionAllowedToUnprotectArgs;
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 branchProtect = new BranchProtection("branchProtect", BranchProtectionArgs.builder()
.project("12345")
.branch("BranchProtected")
.pushAccessLevel("developer")
.mergeAccessLevel("developer")
.unprotectAccessLevel("developer")
.allowForcePush(true)
.codeOwnerApprovalRequired(true)
.allowedToPushes(
BranchProtectionAllowedToPushArgs.builder()
.userId(5)
.build(),
BranchProtectionAllowedToPushArgs.builder()
.userId(521)
.build())
.allowedToMerges(
BranchProtectionAllowedToMergeArgs.builder()
.userId(15)
.build(),
BranchProtectionAllowedToMergeArgs.builder()
.userId(37)
.build())
.allowedToUnprotects(
BranchProtectionAllowedToUnprotectArgs.builder()
.userId(15)
.build(),
BranchProtectionAllowedToUnprotectArgs.builder()
.groupId(42)
.build())
.build());
// Example using dynamic block
var main = new BranchProtection("main", BranchProtectionArgs.builder()
.project("12345")
.branch("main")
.pushAccessLevel("maintainer")
.mergeAccessLevel("maintainer")
.unprotectAccessLevel("maintainer")
.dynamic(%!v(PANIC=Format method: runtime error: invalid memory address or nil pointer dereference))
.build());
}
}
resources:
branchProtect:
type: gitlab:BranchProtection
properties:
project: '12345'
branch: BranchProtected
pushAccessLevel: developer
mergeAccessLevel: developer
unprotectAccessLevel: developer
allowForcePush: true
codeOwnerApprovalRequired: true
allowedToPushes:
- userId: 5
- userId: 521
allowedToMerges:
- userId: 15
- userId: 37
allowedToUnprotects:
- userId: 15
- groupId: 42
# Example using dynamic block
main:
type: gitlab:BranchProtection
properties:
project: '12345'
branch: main
pushAccessLevel: maintainer
mergeAccessLevel: maintainer
unprotectAccessLevel: maintainer
dynamic:
- forEach:
- 50
- 55
- 60
content:
- userId: ${allowed_to_push.value}

Import

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

$ pulumi import gitlab:index/branchProtection:BranchProtection BranchProtect "12345:main"

Properties

Link copied to clipboard

Array of access levels and user(s)/group(s) allowed to merge to protected branch.

Link copied to clipboard

Array of access levels and user(s)/group(s) allowed to push to protected branch.

Link copied to clipboard

Array of access levels and user(s)/group(s) allowed to unprotect push to protected branch.

Link copied to clipboard
val allowForcePush: Output<Boolean>

Can be set to true to allow users with push access to force push.

Link copied to clipboard
val branch: Output<String>

Name of the branch.

Link copied to clipboard
val branchProtectionId: Output<Int>

The ID of the branch protection (not the branch name).

Link copied to clipboard

Can be set to true to require code owner approval before merging. Only available for Premium and Ultimate instances.

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

Access levels allowed to merge. Valid values are: no one, developer, maintainer.

Link copied to clipboard
val project: Output<String>

The id of the project.

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

Access levels allowed to push. Valid values are: no one, developer, maintainer.

Link copied to clipboard

Access levels allowed to unprotect. Valid values are: developer, maintainer, admin.

Link copied to clipboard
val urn: Output<String>