GitLab API

GitlabTool

Actions1000

Overview

This node operation retrieves the content of a specific file from a GitLab project's repository using the GitLab API v4. It is useful for scenarios where you need to programmatically access the contents of files stored in a GitLab repository, such as fetching configuration files, scripts, or documentation directly from the repository. For example, it can be used in CI/CD pipelines or automation workflows to read file contents based on branch, tag, or commit reference.

Use Case Examples

  1. Fetch the README.md file from the main branch of a GitLab project to display its content in a dashboard.
  2. Retrieve a configuration file from a specific commit in a GitLab repository to use in an automated deployment process.

Properties

Name Meaning
Skip Authentication Whether to skip authentication when making the API request. Defaults to false, meaning authentication is used.
Authentication The authentication method used for the API request, defaulting to GitLab API authentication. Hidden if Skip Authentication is true.
baseUrl The base URL of the GitLab instance, defaulting to https://gitlab.com.
Method The HTTP method used for the request, defaulting to GET. Options include GET, POST, PUT, DELETE, HEAD, PATCH.
Query Parameters Query parameters for the API request, specifically the 'ref' parameter which specifies the branch, tag, or commit name to fetch the file from.
Path Parameters Path parameters for the API request, including 'id' which is the project ID or path, and 'file_path' which is the URL-encoded path to the file in the repository.

Output

JSON

  • content - The content of the requested file from the GitLab repository, typically base64 encoded.
  • file_path - The path of the file requested in the repository.
  • ref - The branch, tag, or commit reference used to fetch the file.
  • project_id - The ID or path of the GitLab project from which the file was retrieved.

Dependencies

  • GitLab API authentication credential

Troubleshooting

  • Ensure the project ID and file path are correctly URL encoded and valid in the GitLab repository.
  • Verify that the 'ref' parameter corresponds to an existing branch, tag, or commit in the repository.
  • Check that the GitLab API authentication credentials are correctly configured and have sufficient permissions to access the repository files.
  • Common error messages include 404 Not Found if the file or project does not exist, and 401 Unauthorized if authentication fails.

Links

Discussion