list_pipeline_jobs
Retrieve all jobs from a specific GitLab CI/CD pipeline to monitor execution status and troubleshoot build processes.
Instructions
列出 Pipeline 的所有 Jobs
Args: project_id: 專案 ID 或路徑 pipeline_id: Pipeline ID page: 頁碼 per_page: 每頁筆數
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | ||
| pipeline_id | Yes | ||
| page | No | ||
| per_page | No |
Implementation Reference
- src/gitlab_mcp/gitlab_client.py:339-351 (handler)The GitLabClient method that performs the actual API call to list pipeline jobs.
def list_pipeline_jobs( self, project_id: int | str, pipeline_id: int, page: int = 1, per_page: int = 20, ) -> list[dict]: """GET /projects/:id/pipelines/:pipeline_id/jobs""" pid = self._resolve_project_id(project_id) params = {"page": page, "per_page": per_page} return self._get_json( f"/projects/{pid}/pipelines/{pipeline_id}/jobs", params=params ) - src/gitlab_mcp/server.py:639-680 (registration)The tool handler registered with the MCP server, which processes input and invokes the GitLabClient.
@mcp.tool() def list_pipeline_jobs(project_id: int | str, pipeline_id: int, page: int = 1, per_page: int = 20) -> str: """列出 Pipeline 的所有 Jobs Args: project_id: 專案 ID 或路徑 pipeline_id: Pipeline ID page: 頁碼 per_page: 每頁筆數 """ try: client = get_client() jobs = client.list_pipeline_jobs(project_id, pipeline_id, page=page, per_page=per_page) if not jobs: return "此 Pipeline 沒有 Jobs" status_emoji = { "success": "✅", "failed": "❌", "running": "🔄", "pending": "⏳", "canceled": "⛔", "skipped": "⏭️", "created": "🆕", "manual": "👋" } lines = [f"Pipeline #{pipeline_id} 的 Jobs(共 {len(jobs)} 個):\n"] for j in jobs: emoji = status_emoji.get(j.get("status", ""), "⚪") duration = f"{j['duration']:.1f}秒" if j.get("duration") else "N/A" lines.append( f"{emoji} [{j.get('stage', 'N/A')}] {j['name']} (#{j['id']})" f"\n 狀態: {j.get('status', 'N/A')} | 持續時間: {duration} | {j.get('web_url', '')}\n" ) return "\n".join(lines) except GitLabAPIError as e: return f"列出 Jobs 失敗: {str(e)}" @mcp.tool() def get_job(project_id: int | str, job_id: int) -> str: """取得 Job 詳細資訊 Args: project_id: 專案 ID 或路徑