gitlab_get_job_log
Retrieve GitLab CI job logs with optional filtering to find specific errors or view recent output, enabling efficient debugging of pipeline failures.
Instructions
Fetch the trace/log of a job, with optional regex filter.
Two modes:
Default: return the last
taillines (token-efficient, good for "why did this just fail?").With
grep_pattern: return only matching lines withgrep_contextsurrounding lines on each side — ideal for finding "ERROR" / "Traceback" in megabyte-scale CI logs without pulling the whole trace into context.
Examples:
- "Why did job 789 fail" → default tail=100, look at the end of the log
- "Show me the first stage output of job 789" → tail=5000 and scan for stage separator
- "Find every Traceback in job 789" → grep_pattern='Traceback', grep_context=5
- "All ERROR lines from job 789" → grep_pattern='ERROR|FAIL'
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| job_id | Yes | Numeric job ID (from ``gitlab_get_pipeline_jobs``). | |
| tail | No | Return only the last N lines (1–5000, default 100). | |
| grep_pattern | No | Optional regex — when set, returns only lines matching the pattern (with ``grep_context`` surrounding lines) instead of the tail. Great for finding errors in huge logs without downloading everything. Invalid regex falls back to literal substring match. | |
| grep_context | No | Surrounding lines to include around each grep match (0–20). | |
| project_path | No | GitLab project path (e.g. 'my-org/my-repo'). When omitted, the default from GITLAB_PROJECT_PATH env var is used. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| job_id | No | ||
| total_lines | No | ||
| showing_last | No | ||
| log | No | ||
| grep_pattern | No | ||
| grep_matches | No |