GitLab API icon

GitLab API

Gitlab

Actions917

Overview

This node operation allows users to create or update a file in a GitLab project's repository by making a POST request to the GitLab API endpoint `/api/v4/projects/{id}/repository/files/{file_path}`. It is useful for automating file management tasks within GitLab repositories, such as adding new files or updating existing ones programmatically. For example, it can be used in CI/CD pipelines to update configuration files or documentation automatically.

Use Case Examples

  1. Automatically update a README file in a GitLab project repository when new documentation is generated.
  2. Add a new configuration file to a project repository as part of a deployment process.

Properties

Name Meaning
Skip Authentication Whether to skip authentication for the request (boolean). Defaults to false.
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 to use for the request, default is POST.
Path Parameters Parameters used in the request path to specify the project and file path.

Output

JSON

  • file_path - The path of the file in the repository.
  • branch - The branch name where the file is created or updated.
  • commit_id - The commit ID of the change.
  • content - The content of the file after the operation.

Dependencies

  • GitLab API authentication token or API key credential

Troubleshooting

  • Ensure the project ID and file path are correctly URL-encoded and valid in GitLab.
  • Verify that the authentication token has sufficient permissions to create or update files in the repository.
  • Check that the request body includes all required fields as per the GitLab API specification for this endpoint.
  • Common errors include 404 Not Found if the project or file path is incorrect, and 401 Unauthorized if authentication fails.

Links

Discussion