Actions66
- Branch Actions
- File Actions
- Group Actions
- Issue Actions
- Merge Request Actions
- Pipeline Actions
- Project Actions
- Raw API Actions
- Release Actions
- Tag Actions
Overview
The "GitLab Extended" node provides extended integration with GitLab, allowing users to manage various GitLab resources programmatically within n8n workflows. Specifically, the Branch - Protect operation enables users to protect a branch in a GitLab project, controlling who can push or merge changes to that branch.
This operation is useful in scenarios where teams want to enforce branch protection policies to maintain code quality and prevent unauthorized changes. For example, protecting the main or release branches ensures only authorized developers can push or merge, reducing risks of accidental overwrites or breaking changes.
Practical examples:
- Automatically protect feature branches after creation.
- Enforce developer permissions on critical branches as part of CI/CD pipelines.
- Manage branch protection settings dynamically based on project lifecycle events.
Properties
| Name | Meaning |
|---|---|
| Authentication | Choose between using saved credentials ("Credential") or entering custom connection details ("Custom"). |
| GitLab Server | Base URL of your GitLab instance (e.g., https://gitlab.com). Used only if "Custom" authentication is selected. |
| Access Token | Personal access token with API permissions for authentication. Used only if "Custom" authentication is selected. |
| Project Owner | Namespace or owner of the project. Ignored if "Project ID" is set. Used only if "Custom" authentication is selected. |
| Project Name | Project slug or name. Ignored if "Project ID" is set. Used only if "Custom" authentication is selected. |
| Project ID | Numeric project ID. Takes precedence over owner and name if provided. Used only if "Custom" authentication is selected. |
| Branch | The name of the branch to protect, e.g., feature/login. Required. |
| Developers Can Push | Boolean flag indicating whether developers are allowed to push to the protected branch. Defaults to false. |
| Developers Can Merge | Boolean flag indicating whether developers are allowed to merge into the protected branch. Defaults to false. |
Output
The node outputs JSON data representing the response from the GitLab API after attempting to protect the specified branch. This typically includes details about the protected branch configuration such as:
- Branch name
- Protection status
- Permissions for developers to push or merge
- Other metadata returned by GitLab's branch protection API
No binary data output is involved in this operation.
Dependencies
- Requires an active GitLab instance accessible via API.
- Requires either saved credentials or custom authentication fields including a valid personal access token with appropriate API permissions.
- No additional external dependencies beyond standard HTTP requests to GitLab API.
Troubleshooting
- Invalid or missing project identification: If neither a valid Project ID nor both Project Owner and Project Name are provided (when using custom authentication), the request may fail. Ensure correct project identifiers are supplied.
- Insufficient permissions: The personal access token must have sufficient rights to modify branch protection settings. Errors related to authorization indicate the token lacks required scopes.
- Branch not found: Specifying a non-existent branch name will cause errors. Verify the branch exists in the target project.
- API rate limits or connectivity issues: Network problems or GitLab API rate limiting can cause failures. Check network connectivity and token usage limits.
- Invalid JSON or parameter formats: Although not typical for this operation, ensure all parameters conform to expected types and formats.
Common error messages usually come directly from GitLab API responses and should be interpreted accordingly.