GitLab API icon

GitLab API

Gitlab

Actions880

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 the main branch in multiple projects to enforce workflow policies.

Use Case Examples

  1. Automate branch protection for the 'main' branch in multiple GitLab projects.
  2. Set up branch protection rules as part of a CI/CD pipeline to ensure code quality and security.

Properties

Name Meaning
Skip Authentication Option to skip authentication for the request, useful for public or unauthenticated API access.
Authentication Specifies the authentication method to use, defaulting to GitLab API key authentication.
baseUrl The base URL of the GitLab instance, defaulting to https://gitlab.com.
Method HTTP method to use for the request, default is GET but POST is used for this operation.
Path Parameters Parameters to specify the project ID or URL-encoded path for which the protected branch is being created.

Output

JSON

  • id - The ID or URL-encoded path of the project for which the protected branch is created.
  • protected_branch - Details of the newly created protected branch returned by the GitLab API.

Dependencies

  • GitLab API key credential for authentication

Troubleshooting

  • Ensure the project ID or path is correctly URL-encoded and valid to avoid 404 errors.
  • Authentication errors may occur if the API key is missing or invalid; verify credentials.
  • The API may return validation errors if required fields in the request body are missing or incorrect; check the request schema and required parameters.

Links

Discussion