GitLab API

GitlabTool

Actions905

Overview

This node operation retrieves information about a specific protected branch in a GitLab project using the GitLab API v4. It is useful for scenarios where you need to programmatically access branch protection details, such as branch name, access levels, and rules, for automation or integration purposes. For example, it can be used in CI/CD pipelines to verify branch protection settings before deployment.

Use Case Examples

  1. Get details of the 'main' protected branch in the 'gitlab-org/gitlab' project to check its access rules.
  2. Fetch protected branch information to audit branch protection policies across multiple projects.

Properties

Name Meaning
Skip Authentication Option to skip authentication for the API request.
Authentication Type of authentication used for the API request, defaulting to 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.
Parameter Schema Defines the required path parameters 'id' (project ID or URL-encoded path) and 'name' (branch name or wildcard) for the API endpoint.
Request Body Schema Schema for the request body, null for this GET operation.
Request Path API endpoint path template for accessing the protected branch resource.
Path Parameters Collection of path parameters 'id' and 'name' used to specify the project and branch in the API call.

Output

JSON

  • id - ID of the protected branch.
  • 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 into the branch.
  • unprotect_access_levels - Access levels allowed to unprotect the branch.
  • allow_force_push - Indicates if force push is allowed on the branch.
  • code_owner_approval_required - Indicates if code owner approval is required for the branch.

Dependencies

  • GitLab API key credential for authentication

Troubleshooting

  • Ensure the project ID or URL-encoded path and branch name are correctly specified; incorrect values will cause API errors.
  • Authentication errors may occur if the GitLab API key is missing or invalid; verify credentials.
  • Permission errors can happen if the API user does not have access to the project or branch; check user permissions.

Links

Discussion