GitLab API

GitlabTool

Actions1000

Overview

This node operation allows users to create or update CI/CD variables for a specific project in GitLab by making a POST request to the GitLab API endpoint `/api/v4/projects/{id}/variables`. It is useful for automating the management of project-level environment variables used in GitLab CI/CD pipelines, such as setting secrets or configuration values programmatically.

Use Case Examples

  1. Automate adding or updating CI/CD variables for a GitLab project during deployment workflows.
  2. Manage project variables dynamically based on environment or branch conditions in CI/CD pipelines.

Properties

Name Meaning
Skip Authentication Option to skip authentication for the request, useful for public or unauthenticated API calls.
Authentication Specifies the authentication method to use, defaulting to GitLab API key authentication.
baseUrl The base URL of the GitLab instance, defaulting to https://gitlab.com.
Method HTTP method to use for the request, default is GET but POST is used for this operation.
Path Parameters Parameters to specify the project ID or URL-encoded namespace/project name for which the CI variables are managed.

Output

JSON

  • id - The ID or URL-encoded namespace/project name of the GitLab project.
  • key - The key/name of the CI variable being created or updated.
  • value - The value of the CI variable.
  • variable_type - The type of the variable (e.g., env_var).
  • protected - Indicates if the variable is protected.
  • masked - Indicates if the variable is masked.
  • environment_scope - The environment scope for the variable.

Dependencies

  • GitLab API key credential for authentication

Troubleshooting

  • Ensure the project ID or namespace/project name is correctly URL-encoded and valid.
  • Verify that the GitLab API key credential has sufficient permissions to create or update project variables.
  • Check that the base URL is correct and accessible.
  • If skipping authentication, ensure the API endpoint allows unauthenticated requests, otherwise authentication errors will occur.
  • Common error messages include 401 Unauthorized (invalid or missing API key), 404 Not Found (invalid project ID), and 400 Bad Request (invalid variable data). Resolving these involves verifying credentials, project existence, and request payload correctness.

Links

Discussion