Summary
Implement the GitlabMergeRequestSource struct that fetches GitLab merge requests via the REST API v4, converting them to Task objects with MR-specific metadata (source branch, target branch, merge status).
Context
The scaffolding from the foundation issue provides GitlabConfig (auth/URL), the TriggerConfig::GitlabMergeRequests variant, and stub TaskSource implementation. This issue replaces the stub with real API calls.
GitLab REST API v4 endpoint: GET /api/v4/projects/:id/merge_requests
- Project identified by
owner%2Frepo (URL-encoded namespace/project)
- Supports query params:
labels, state, assignee_id (requires user lookup)
- Returns JSON array of MR objects with branch info
- Pagination via
per_page and page params
Acceptance Criteria
GitLab API Response Shape (relevant fields)
{
"iid": 15,
"title": "Add new feature",
"description": "This MR adds...",
"web_url": "https://gitlab.com/myorg/myrepo/-/merge_requests/15",
"state": "opened",
"labels": ["enhancement"],
"assignees": [{"username": "bob"}],
"source_branch": "feature/new-thing",
"target_branch": "main",
"merge_status": "can_be_merged",
"draft": false,
"project_id": 12345
}
Key Files
crates/orchestrator/src/scheduler/gitlab.rs - main implementation
Blocked By
- The GitLab scaffolding issue (config and type variants must exist)
Stack Base
Branch off: feature/autonomous-pipeline
Blocked by: #1180
Summary
Implement the
GitlabMergeRequestSourcestruct that fetches GitLab merge requests via the REST API v4, converting them toTaskobjects with MR-specific metadata (source branch, target branch, merge status).Context
The scaffolding from the foundation issue provides
GitlabConfig(auth/URL), theTriggerConfig::GitlabMergeRequestsvariant, and stubTaskSourceimplementation. This issue replaces the stub with real API calls.GitLab REST API v4 endpoint:
GET /api/v4/projects/:id/merge_requestsowner%2Frepo(URL-encoded namespace/project)labels,state,assignee_id(requires user lookup)per_pageandpageparamsAcceptance Criteria
GitlabMergeRequestSource::fetch_tasks()makes authenticated HTTP GET to GitLab API{base_url}/api/v4/projects/{owner}%2F{repo}/merge_requestsstate(default:opened)labels(comma-separated)assignee_username(whenassigneesfield is set, query once per assignee or use appropriate API filter)per_page=100for efficient batchingTask:source_id= MRiid(project-scoped MR number)title= MR titlebody= MR descriptionurl= MRweb_urllabels= MR labels arrayassignee= first assignee's usernamemetadata:gitlab_project_id,gitlab_iid,source_branch,target_branch,merge_status,draft(boolean),statePRIVATE-TOKENheader with resolved tokenwarnlevel with status codesource_type()returns"gitlab_merge_requests"GitLab API Response Shape (relevant fields)
{ "iid": 15, "title": "Add new feature", "description": "This MR adds...", "web_url": "https://gitlab.com/myorg/myrepo/-/merge_requests/15", "state": "opened", "labels": ["enhancement"], "assignees": [{"username": "bob"}], "source_branch": "feature/new-thing", "target_branch": "main", "merge_status": "can_be_merged", "draft": false, "project_id": 12345 }Key Files
crates/orchestrator/src/scheduler/gitlab.rs- main implementationBlocked By
Stack Base
Branch off:
feature/autonomous-pipelineBlocked by: #1180