GitLab API

GitlabTool

Actions905

Overview

This node operation retrieves the common ancestor (merge base) of specified refs in a GitLab project's repository. It is useful for determining the base commit from which branches diverged, which is essential in merge conflict resolution, code review, and CI/CD workflows. For example, it can be used to find the merge base between two branches before creating a merge request.

Use Case Examples

  1. Find the merge base between 'main' and 'feature-branch' in a project to prepare for a merge request.
  2. Determine the common ancestor commit of multiple refs to analyze changes in a GitLab repository.

Properties

Name Meaning
Skip Authentication Whether to skip authentication for the request.
Authentication The authentication method used for the request, typically an API key credential for GitLab.
baseUrl The base URL of the GitLab instance, defaulting to https://gitlab.com.
Method The HTTP method used for the request, default is GET.
Query Parameters Query parameters for the request, specifically 'refs' which are the refs to find the common ancestor of. Multiple refs can be passed as a string representing an array.
Path Parameters Path parameters for the request, specifically 'id' which is the ID or URL-encoded path of the project.

Output

JSON

  • merge_base_commit - The commit object representing the common ancestor (merge base) of the specified refs.

Dependencies

  • GitLab API authentication credential

Troubleshooting

  • Ensure the 'id' path parameter is correctly set to the project ID or URL-encoded path; otherwise, the request will fail.
  • The 'refs' query parameter must be provided and correctly formatted as an array of strings representing branch or tag names; missing or incorrect refs will cause errors.
  • Authentication errors may occur if the API key credential is missing or invalid; verify the GitLab API token and permissions.
  • Network or base URL misconfiguration can cause connection failures; confirm the baseUrl is correct for your GitLab instance.

Links

Discussion