gitlab_trigger_pipeline
Trigger a new GitLab CI/CD pipeline for a specific branch or ref to automate code testing and deployment processes.
Instructions
Triggers a new pipeline for a specific branch/ref.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectPath | Yes | The path of the GitLab project. | |
| ref | Yes | The branch or ref to trigger the pipeline for. | |
| variables | No | Optional: Pipeline variables as key-value pairs. |
Implementation Reference
- src/gitlab.service.ts:574-586 (handler)Core handler function implementing the gitlab_trigger_pipeline tool. Posts to GitLab API to create a new pipeline for the specified project and ref, with optional variables.// New tool: Trigger Pipeline async triggerPipeline(projectPath: string, ref: string, variables?: Record<string, string>): Promise<any> { const encodedProjectPath = encodeURIComponent(projectPath); const body: any = { ref }; if (variables) { body.variables = Object.entries(variables).map(([key, value]) => ({ key, value })); } return this.callGitLabApi<any>( `projects/${encodedProjectPath}/pipeline`, 'POST', body, ); }
- src/index.ts:697-717 (registration)Registers the gitlab_trigger_pipeline tool in the MCP tools list, including name, description, and input schema.name: 'gitlab_trigger_pipeline', description: 'Triggers a new pipeline for a specific branch/ref.', inputSchema: { type: 'object', properties: { projectPath: { type: 'string', description: 'The path of the GitLab project.', }, ref: { type: 'string', description: 'The branch or ref to trigger the pipeline for.', }, variables: { type: 'object', description: 'Optional: Pipeline variables as key-value pairs.', }, }, required: ['projectPath', 'ref'], }, },
- src/index.ts:1840-1854 (registration)Dispatch handler in the MCP server request handler that calls the GitLab service's triggerPipeline method for the gitlab_trigger_pipeline tool.case 'gitlab_trigger_pipeline': { if (!gitlabService) { throw new Error('GitLab service is not initialized.'); } const { projectPath, ref, variables } = args as { projectPath: string; ref: string; variables?: Record<string, string> }; const result = await gitlabService.triggerPipeline(projectPath, ref, variables); return { content: [ { type: 'text', text: `Pipeline triggered successfully: ${JSON.stringify(result, null, 2)}`, }, ], }; }