gitlab_get_pipeline_jobs
Retrieve jobs from a specific GitLab pipeline to monitor execution status and identify issues in CI/CD workflows.
Instructions
Gets jobs for a specific pipeline.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectPath | Yes | The path of the GitLab project. | |
| pipelineId | Yes | The ID of the pipeline. |
Implementation Reference
- src/gitlab.service.ts:547-552 (handler)The core handler function implementing the gitlab_get_pipeline_jobs tool. It encodes the project path and calls the GitLab API to retrieve the list of jobs for the specified pipeline.async getPipelineJobs(projectPath: string, pipelineId: number): Promise<any[]> { const encodedProjectPath = encodeURIComponent(projectPath); return this.callGitLabApi<any[]>( `projects/${encodedProjectPath}/pipelines/${pipelineId}/jobs`, ); }
- src/index.ts:660-677 (registration)Registration of the 'gitlab_get_pipeline_jobs' tool in the MCP tools list, including its description and input schema definition.{ name: 'gitlab_get_pipeline_jobs', description: 'Gets jobs for a specific pipeline.', inputSchema: { type: 'object', properties: { projectPath: { type: 'string', description: 'The path of the GitLab project.', }, pipelineId: { type: 'number', description: 'The ID of the pipeline.', }, }, required: ['projectPath', 'pipelineId'], }, },
- src/index.ts:1808-1822 (handler)MCP request handler case for 'gitlab_get_pipeline_jobs' that validates GitLab service availability, extracts arguments, calls the service method, and returns the JSON-formatted result.case 'gitlab_get_pipeline_jobs': { if (!gitlabService) { throw new Error('GitLab service is not initialized.'); } const { projectPath, pipelineId } = args as { projectPath: string; pipelineId: number }; const result = await gitlabService.getPipelineJobs(projectPath, pipelineId); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
- src/gitlab.service.ts:22-51 (helper)Helper method used by getPipelineJobs to make authenticated HTTP requests to the GitLab API, handling errors and JSON parsing.private async callGitLabApi<T>( endpoint: string, method: string = 'GET', body?: object, ): Promise<T> { const url = `${this.config.url}/api/v4/${endpoint}`; const headers = { 'Private-Token': this.config.accessToken, 'Content-Type': 'application/json', }; const options: any = { method, headers, body: body ? JSON.stringify(body) : undefined, }; try { const response = await fetch(url, options); if (!response.ok) { const errorText = await response.text(); console.error(`GitLab API Error: ${response.status} - ${errorText}`); throw new Error(`GitLab API Error: ${response.status} - ${errorText}`); } return response.json() as Promise<T>; } catch (error) { console.error(`Failed to call GitLab API: ${error}`); throw error; } }