gitlab_create_snippet
Create and share reusable code snippets in GitLab for saving solutions, documenting examples, and sharing code with customizable visibility settings.
Instructions
Create a new code snippet Creates: New snippet with specified content and metadata Use when: Saving reusable code, sharing solutions, documenting examples Required: title, file_name, content Optional: description, visibility
Example usage: { "title": "Docker Compose Template", "file_name": "docker-compose.yml", "content": "version: '3.8'\nservices:\n app:\n image: nginx", "description": "Basic Docker Compose setup", "visibility": "internal" }
Returns: Created snippet with ID and URLs
Related tools:
gitlab_update_snippet: Modify after creation
gitlab_list_snippets: View created snippets
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | No | Project identifier (auto-detected if not provided) Type: integer OR string Format: numeric ID or 'namespace/project' Optional: Yes - auto-detects from current git repository Examples: - 12345 (numeric ID) - 'gitlab-org/gitlab' (namespace/project path) - 'my-group/my-subgroup/my-project' (nested groups) Note: If in a git repo with GitLab remote, this can be omitted | |
| title | Yes | Snippet title Type: string Format: Descriptive title for the snippet Example: 'Database migration script' Note: Required when creating snippets | |
| file_name | Yes | Snippet file name Type: string Format: File name with extension Example: 'migration.sql', 'helper.py', 'config.yaml' Note: Used for syntax highlighting and display | |
| content | Yes | Snippet content Type: string Format: Raw text content of the snippet Example: 'console.log("Hello World");' Note: Can be code, text, or any content type | |
| description | No | Snippet description Type: string Format: Optional description of the snippet Example: 'Helper script for database migrations' Note: Provides context about the snippet's purpose | |
| visibility | No | Snippet visibility Type: string Format: Visibility level for the snippet Options: 'private' | 'internal' | 'public' Default: 'private' Examples: - 'private' (only visible to author) - 'internal' (visible to authenticated users) - 'public' (visible to everyone) | private |