GitLab API

GitlabTool

Actions1000

Overview

This node operation allows users to create a protected branch in a specific GitLab project by making a POST request to the GitLab API endpoint `/api/v4/projects/{id}/protected_branches`. It is useful for managing branch protection settings programmatically, such as restricting who can push or merge to certain branches in a project. For example, a user can automate the protection of release branches to ensure only authorized users can modify them.

Use Case Examples

  1. Automate branch protection for release branches in a CI/CD pipeline.
  2. Manage branch protection settings across multiple projects programmatically.

Properties

Name Meaning
Skip Authentication Option to skip authentication for the request, default is false.
Authentication Type of authentication used, hidden unless Skip Authentication is false. Default is GitLab API key.
baseUrl Base URL of the GitLab instance, default is https://gitlab.com.
Method HTTP method to use for the request, default is GET. For this operation, POST is used.
Path Parameters Parameters to be included in the request path, specifically the project ID or URL-encoded path.

Output

JSON

  • id - ID of the protected branch created.
  • name - Name of the protected branch.
  • push_access_levels - Access levels allowed to push to the branch.
  • merge_access_levels - Access levels allowed to merge to the branch.
  • unprotect_access_levels - Access levels allowed to unprotect the branch.

Dependencies

  • GitLab API key credential

Troubleshooting

  • Ensure the project ID or URL-encoded path is correct to avoid 404 errors.
  • Verify that the authentication token has sufficient permissions to create protected branches.
  • Check the request body schema matches the expected format to prevent validation errors.

Links

Discussion