Retrieve and analyze GitLab merge request comments and metadata using authenticated API calls
72
91%
Does it follow best practices?
Impact
—
No eval scenarios have been run
Advisory
Suggest reviewing before use
Retrieve and analyze GitLab merge request comments and metadata using authenticated API calls.
GITLAB_TOKEN or GITLAB_PAT with read_api scopecurl, jqFetches all comments from a GitLab merge request.
Location: .agents/skills/gitlab-api/scripts/get_mr_comments.sh
Usage:
.agents/skills/gitlab-api/scripts/get_mr_comments.sh <merge_request_url>Example:
# Prerequisites assumed: GITLAB_TOKEN with read_api scope
.agents/skills/gitlab-api/scripts/get_mr_comments.sh "https://gitlab.com/your-group/your-project/-/merge_requests/123"Output Format:
---
Author: Name (@username)
Date: ISO8601 timestamp (UTC)
Type: DiffNote|comment
System: true|false
Comment body textSystem: true — automated/system-generated message; System: false — human commentType: DiffNote — inline code review comment; Type: comment — general MR commentExit Codes:
0: Success1: Invalid URL format, missing token, or API errorWhen to Examine Script Internals:
Read script source when debugging unexpected output, extending for custom metadata, or understanding URL encoding. For basic usage, the examples above suffice.
Script location: .agents/skills/gitlab-api/scripts/get_mr_comments.sh (~80 lines)
output=$(.agents/skills/gitlab-api/scripts/get_mr_comments.sh "$MR_URL")
echo "$output" | grep -q "Author:" || { echo "Invalid response — check token and URL"; exit 1; }System: false to exclude automated messagesoutput=$(.agents/skills/gitlab-api/scripts/get_mr_comments.sh "$MR_URL")
[ -n "$output" ] && echo "$output" | grep -q "Date:" || { echo "Empty or malformed response — check credentials"; exit 1; }401 Unauthorized: Token missing or invalid
GITLAB_TOKEN or GITLAB_PAT is set404 Project Not Found: Invalid project path
https://gitlab.com/group/project/-/merge_requests/IDGITLAB_TOKEN="glpat-xxxx" inline in a script committed to version control.$GITLAB_TOKEN) or a secrets manager; document the required scope in README.?per_page=100 without loop handlingX-Next-Page response header.curl .../merge_requests?per_page=100 assuming this returns all MRs.X-Next-Page is empty: check the header in each response and fetch the next page.429 Too Many Requests responses.429 status codes and implement exponential backoff; use the Retry-After header when provided.v3 API endpointv4.https://gitlab.com/api/v3/projects/...https://gitlab.com/api/v4/projects/...jq for JSON parsing, never grep on raw API JSON%2F for / in project paths)