GitLab Branch Protect logo

GitLab Branch Protect Version 1

Protects a specified branch through push and merge rules in an existing GitLab project using a user's private token (obtained in GitLab under the intended user's 'Settings' => 'Account'). The branch to be protected is found through providing the projects path (which is the project name provided in the URL - not necessarily the same as the readable name) and the branch name. Once the project is found, the push and merge capabilities can be enforced in the following 3 levels: 'none' means no one can modify the branch while 'masters'/'developers' map to the 'Master'/'Developer' GitLab Member permissions for the specified project. If 'Allowed to push' or 'Allowed to merge' is not provided, it will either stay the same as before if edited an already protected branch or default to 'masters' if this is a new protected branch. An empty result set will be returned on a successful branch protection attempt.

Parameters

Name Description
Project Group Path of the group where the project and branch are located (defaults to the GitLab default group if not provided).
Project Path Path of the project where the branch is located.
Branch Name of the branch.
Allowed To Push Who should be allowed to push to the branch: 'none','masters','developers'.
Allowed To Merge Who should be allowed to merge to the branch: 'none','masters','developers'.

Sample Configuration

Name Description
Project Group super-secret-group
Project Path test-project
Branch master
Allowed To Push none
Allowed To Merge masters

Results

This handler does not return any results.

Changelog

GitLab Branch Protect V1 (2017-10-02)

  • Initial version. See README for details.


Related Handlers

GitLab Branch Create
Creates a new branch in an existing GitLab project.
GitLab File Create
Creates a new file in an existing GitLab project.
GitLab Project Create
Creates a new project in GitLab.
GitLab Webhook Create
Creates a new webhook for an existing GitLab project.