An autonomous SRE agent that watches for CI/CD pipeline failures in GitLab, investigates root causes using Gemini, and automatically creates issues and MR comments — so your on-call engineer wakes up to a pre-filled incident ticket instead of raw log noise.
Built for the Google Cloud Rapid Agent Hackathon — GitLab track.
Stack: Google Agent Development Kit (ADK) · Gemini 2.0 Flash · GitLab MCP Server · Cloud Run
When a GitLab pipeline fails, the agent automatically:
- Fetches pipeline details and job logs (via GitLab MCP)
- Lists recent commits on the failing branch
- Identifies the merge request that triggered the pipeline
- Searches for similar past incidents in the project
- Creates a structured GitLab issue with root cause, suspect commit, and fix suggestion
- Comments on the MR with a summary and link to the issue
- Returns a structured incident report
All without a human clicking anything.
GitLab Pipeline Failure
│
▼ (webhook)
Cloud Run (server.py)
│
▼
Google ADK Runner
└── Gemini 2.0 Flash
│
▼ (MCP tools)
GitLab MCP Server
├── get_pipeline / get_job_log
├── list_commits
├── get_merge_request
├── search_issues
├── create_issue
└── create_mr_note
- Go to console.cloud.google.com and create a free account
- Create a new project (e.g.
gitlab-incident-agent) - Enable billing (required for Cloud Run — free tier is generous)
- Enable these APIs:
gcloud services enable run.googleapis.com \ cloudbuild.googleapis.com \ aiplatform.googleapis.com \ secretmanager.googleapis.com - Install the gcloud CLI and run:
gcloud auth login gcloud config set project YOUR_PROJECT_ID
- Go to gitlab.com and create a free account
- Create a test project (or use an existing one with CI pipelines)
- Generate a Personal Access Token:
- User Settings → Access Tokens → Add new token
- Scopes:
api,read_repository - Copy the token — you won't see it again
# Python 3.11+ required
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
# Node.js 18+ required (for the GitLab MCP server)
# Download from: https://nodejs.orgcp .env.example .env
# Edit .env and fill in GITLAB_TOKEN and GOOGLE_CLOUD_PROJECTadk webOpens a browser UI at http://localhost:8000. You can type incident scenarios like:
"Pipeline #123 failed on branch feature/auth in project mygroup/myrepo. Investigate and create an issue."
python server.pyThen use ngrok to expose it locally:
ngrok http 8080Copy the ngrok HTTPS URL, then set it as a GitLab webhook:
- Project → Settings → Webhooks
- URL:
https://YOUR-NGROK-URL/webhook/pipeline - Trigger: Pipeline events
- Secret token: same value as
GITLAB_WEBHOOK_SECRETin.env
Now trigger a pipeline failure and watch the agent work.
gcloud builds submit --config cloudbuild.yamlThis builds the Docker image, pushes it to Container Registry, and deploys to Cloud Run.
# Store your GitLab token in Secret Manager (don't bake it into the image)
echo -n "glpat-xxxx" | gcloud secrets create gitlab-token --data-file=-
echo -n "your-webhook-secret" | gcloud secrets create gitlab-webhook-secret --data-file=-
# Allow Cloud Run to read the secrets
gcloud secrets add-iam-policy-binding gitlab-token \
--member="serviceAccount:$(gcloud iam service-accounts list --format='value(email)' | head -1)" \
--role="roles/secretmanager.secretAccessor"gcloud run services describe gitlab-incident-agent \
--region=us-central1 \
--format='value(status.url)'Use this URL + /webhook/pipeline as your GitLab webhook endpoint.
gitlab-incident-agent/
├── agent.py # ADK agent definition + system prompt
├── server.py # FastAPI webhook server
├── requirements.txt
├── Dockerfile
├── cloudbuild.yaml # GCP CI/CD pipeline
├── .env.example
└── README.md
| Criterion | How this project addresses it |
|---|---|
| Move beyond chat | Agent uses 6+ GitLab tools to actually investigate and create artifacts |
| Multi-step mission | Investigate → Analyze → Act (issue + MR comment) — all automated |
| Partner power | Deep GitLab MCP integration: logs, commits, MRs, issues, comments |
| Real-world challenge | Solves a genuine SRE pain point (on-call alert fatigue) |
Apache 2.0 — see LICENSE