GitLab API

GitlabTool

Actions1000

Overview

This node operation retrieves information about a specific branch in a GitLab project repository using the GitLab API. It is useful for scenarios where you need to get details about a particular branch, such as its commit history, protection status, or other metadata. For example, developers or DevOps engineers can use this node to programmatically check branch details before performing automated deployments or merges.

Use Case Examples

  1. Get details of the 'main' branch in a project with ID '12345' to verify its latest commit before deployment.
  2. Fetch branch information to check if a branch is protected before allowing a merge request.

Properties

Name Meaning
Skip Authentication Option to skip authentication when making the API request.
Authentication Type of authentication used for the API request, defaulting to GitLab API key authentication.
baseUrl The base URL of the GitLab instance, defaulting to https://gitlab.com.
Method HTTP method used for the API request, default is GET.
Path Parameters Parameters used in the API request path to specify the project ID and branch name.

Output

JSON

  • id - The ID or URL-encoded path of the project.
  • branch - The name of the branch retrieved from the repository.
  • commit - Details about the latest commit on the branch, including commit ID, message, author, and date.
  • protected - Indicates if the branch is protected.
  • merged - Indicates if the branch has been merged.
  • developers_can_push - Indicates if developers have push access to the branch.
  • developers_can_merge - Indicates if developers have merge access to the branch.
  • can_push - Indicates if the current user can push to the branch.

Dependencies

  • GitLab API key credential

Troubleshooting

  • Ensure the project ID and branch name are correctly specified and URL-encoded if necessary.
  • If authentication is enabled, verify that the GitLab API key credential is valid and has sufficient permissions to access the project repository.
  • Check the base URL to ensure it points to the correct GitLab instance, especially if using a self-hosted GitLab server.
  • Common error messages include 404 Not Found if the project or branch does not exist, and 401 Unauthorized if authentication fails. Verify parameters and credentials accordingly.

Links

Discussion