gitlab

bởi microsoft

Quản lý merge request và pipeline GitLab bằng CLI Python - Được mang đến bởi microsoft/hve-core

npx skills add https://github.com/microsoft/hve-core --skill gitlab

GitLab Skill

Overview

Use this skill to inspect and update GitLab merge requests, notes, pipelines, and job logs against GitLab.com or self-managed GitLab instances.

This skill is the repository-local Python workflow for GitLab tasks. It is not the official GitLab MCP server integration surface.

This first hve-core implementation is Python-only. Run the CLI through python scripts/gitlab.py and prefer --fields for read operations to keep output concise.

Prerequisites

The skill requires Python 3.11 or later.

Set these environment variables before running any command:

VariableRequiredExamplePurpose
GITLAB_URLYeshttps://gitlab.comGitLab instance URL
GITLAB_AUTH_MODEOptionaloauthoauth or explicit legacy-token compatibility mode
GITLAB_OAUTH_CLIENT_IDOAuthApplication IDNon-confidential OAuth application ID; no client secret
GITLAB_TOKENLegacy modeglpat-...PAT accepted only with GITLAB_AUTH_MODE=legacy-token
GITLAB_PROFILENodefaultNamed OAuth profile
GITLAB_TOKEN_STORENopathOAuth store override; parent must be owner-only on POSIX
GITLAB_ALLOW_INSECURENo1Permit explicit loopback HTTP development endpoints only
XDG_DATA_HOMENopathPOSIX data root used for the default OAuth store
LOCALAPPDATANopathReserved Windows data root; OAuth persistence currently fails closed on Windows
GITLAB_PROJECTNogroup/projectProject path or numeric project ID

If GITLAB_PROJECT is not set, the script attempts to detect the project from git remote get-url origin. Set the variable explicitly when you are not in a git repository or when you want to target a different project.

Operational Variables

VariableRequiredPurpose
GITLAB_AUDIT_LOGNoPath to a JSON Lines audit log. When set, every request is audited (see Audit Logging).
GITLAB_AUDIT_ACTORNoOverrides the recorded actor identity (for example, a CI service principal).
GITLAB_DEBUGNoSet to 1 to print a redacted traceback on failure. Never disables redaction.

Audit Logging

When GITLAB_AUDIT_LOG is set, the script writes a structured JSON Lines audit trail for every REST API and OAuth form request. Auditing is fail-closed and write-ahead:

  • An attempt record is written before the request is sent. If the audit log cannot be written, the operation is aborted and nothing is sent to GitLab.
  • An outcome record (success or error, with HTTP status on failure) is written after the request completes.

REST records include a UTC timestamp, actor, auth mode, normalized origin, operation, HTTP method, and event. OAuth records use bounded operation and failure kinds without actor, origin, client, profile, code, body, or free-form error fields. Resource paths, queries, profile names, and profile contents are excluded. The optional audit sink is operationally sensitive because origins can identify tenants or internal hosts. Place it at an access-controlled path and retain it only as long as operations require. Tokens and authorization headers are never written. Audit failures after the request emit a warning without altering the result.

Credential Rotation

OAuth is the default. Register a non-confidential user-, group-, or self-managed instance-owned application with redirect URI http://127.0.0.1:8766/callback and the api scope. Set only GITLAB_URL and GITLAB_OAUTH_CLIENT_ID, then run auth login or the human-assisted auth device-login. Browser login requires a rotating refresh token; access tokens refresh before expiry and replacements are stored atomically. Device login can return an access-token-only profile and then requires another device login after expiry. A provider/local crash window can still require re-login.

The default store is $XDG_DATA_HOME/hve-core/gitlab/gitlab-token.json on POSIX, falling back to ~/.local/share/hve-core/gitlab/gitlab-token.json. POSIX store and lock files use mode 0600 inside a dedicated owner-only directory. OAuth profile persistence fails closed on Windows because Python 3.11 mode bits cannot enforce an owner-only DACL. Use explicit legacy-token mode on Windows until a protected OAuth backend is available.

PAT authentication remains available through GITLAB_AUTH_MODE=legacy-token. Device authorization requires user approval on a browser-capable device and is not unattended workload identity.

Quick Start

Export your environment variables, then run a read command with --fields.

export GITLAB_URL="https://gitlab.com"
export GITLAB_OAUTH_CLIENT_ID="your-application-id"
export GITLAB_PROJECT="group/project"

python scripts/gitlab.py auth login
python scripts/gitlab.py mr-list opened --fields iid,title,author.name

Read pipeline jobs for a known pipeline:

python scripts/gitlab.py pipeline-jobs 12345 --fields id,name,status,stage

Parameters Reference

Common Option

ParameterApplies ToExampleDescription
--fieldsmr-list, mr-get, mr-notes, pipeline-get, pipeline-jobs--fields iid,title,stateExtract specific fields with dot notation and print concise tabular or key-value output

Commands

CommandArgumentsDescription
auth loginNoneAuthenticate with Authorization Code and PKCE
auth device-loginNoneAuthenticate through human-assisted device authorization
auth statusNonePrint secret-free local profile status
auth logoutNoneDelete one local profile without revoking server authorization
mr-list[state] [max]List merge requests, defaulting to all states and 20 results
mr-get<mr-iid>Get one merge request by project-scoped IID
mr-create<json> or stdinCreate a merge request from a JSON payload
mr-update<mr-iid> <json> or stdinUpdate merge request fields from a JSON payload
mr-comment<mr-iid> <body> or stdinAdd a comment to a merge request
mr-notes<mr-iid> [max]List merge request notes, excluding system notes when using --fields
pipeline-get<pipeline-id>Get one pipeline by numeric ID
pipeline-run<branch-or-tag>Trigger a pipeline for a branch or tag
pipeline-jobs<pipeline-id>List jobs for a pipeline
job-log<job-id>Print raw log output for a job

Script Reference

List recent open merge requests:

python scripts/gitlab.py mr-list opened --fields iid,title,author.name,user_notes_count

Get one merge request:

python scripts/gitlab.py mr-get 42 --fields iid,title,state,source_branch,target_branch

Create a merge request from inline JSON:

python scripts/gitlab.py mr-create '{
  "source_branch": "feature/add-auth",
  "target_branch": "main",
  "title": "feat(auth): add OAuth login"
}'

Add a merge request comment from standard input:

echo "CI passed. Ready for review." | python scripts/gitlab.py mr-comment 42

Inspect a failed pipeline:

python scripts/gitlab.py pipeline-get 12345 --fields id,status,web_url
python scripts/gitlab.py pipeline-jobs 12345 --fields id,name,status,stage
python scripts/gitlab.py job-log 67890

Troubleshooting

SymptomCauseResolution
GITLAB_URL is not setRequired environment variable missingExport GITLAB_URL before running the script
GITLAB_TOKEN is not set for legacy-token modeExplicit legacy mode has no PATExport a PAT only with GITLAB_AUTH_MODE=legacy-token
GITLAB_TOKEN must not be set in oauth modeLegacy PAT leaked into the OAuth configurationRemove GITLAB_TOKEN or explicitly select legacy-token mode
OAuth persistence is unavailable on WindowsNo protected Windows profile-store backendUse explicit legacy-token mode or run OAuth from POSIX
GITLAB_OAUTH_CLIENT_ID is not setOAuth application is not configuredSet the public client ID, then run auth login
Callback listener cannot bindPort 8766 is unavailable or not forwardedFree the port or use auth device-login
timed out waiting for the GitLab OAuth token store lockAnother process holds the profile-store lockWait for the other command to finish, then retry
GitLab device response has invalid verification_uriThe verification URI is unsafe to display or does not match GITLAB_URLConfirm GITLAB_URL matches the instance that serves device verification
cannot parse git remote URLProject autodetection failedSet GITLAB_PROJECT explicitly
HTTP 401 or HTTP 403Credential is invalid or lacks accessRe-login for OAuth; rotate the PAT in explicit legacy mode
HTTP 404Wrong project, MR IID, pipeline ID, or job IDVerify GITLAB_PROJECT and confirm the numeric identifiers
expected numeric IDNon-numeric value passed to an ID argumentUse project MR IID values and numeric pipeline or job IDs
python3 is required or syntax errors on launchUnsupported interpreterRun the script with Python 3.11 or later

GitLab uses MR IIDs such as !42 inside a project. This skill expects the numeric IID, not the global merge request ID.

Thêm skills từ microsoft

oss-growth
microsoft
Cá tính tăng trưởng OSS
agent-framework-azure-ai-py
microsoft
Xây dựng các tác nhân Azure AI Foundry bằng SDK Python của Microsoft Agent Framework (agent-framework-azure-ai). Sử dụng khi tạo các tác nhân bền vững với AzureAIAgentsProvider, sử dụng các công cụ được lưu trữ (trình thông dịch mã, tìm kiếm tệp, tìm kiếm web), tích hợp máy chủ MCP, quản lý chuỗi hội thoại hoặc triển khai phản hồi phát trực tuyến. Bao gồm các công cụ hàm, đầu ra có cấu trúc và các tác nhân đa công cụ.
development
airunway-aks-setup
microsoft
Thiết lập AI Runway trên AKS — từ cụm trống đến mô hình đang chạy. Bao gồm xác minh cụm, cài đặt controller, đánh giá GPU, thiết lập nhà cung cấp và triển khai đầu tiên. KHI NÀO: "thiết lập AI Runway", "onboard cụm AKS", "cài đặt AI Runway", "thiết lập airunway", "triển khai mô hình lên AKS", "suy luận GPU trên AKS", "thiết lập KAITO trên AKS", "chạy LLM trên AKS", "vLLM trên AKS", "thiết lập phục vụ mô hình trên AKS", "AI Runway controller".
devops
appinsights-instrumentation
microsoft
Hướng dẫn để instrument các ứng dụng web với Azure Application Insights. Cung cấp các mẫu telemetry, thiết lập SDK, và tài liệu tham khảo cấu hình. KHI NÀO: cách instrument ứng dụng, App Insights SDK, các mẫu telemetry, App Insights là gì, hướng dẫn Application Insights, ví dụ instrumentation, các phương pháp tốt nhất APM.
devops
applicationinsights-web-ts
microsoft
Instrument các ứng dụng trình duyệt/web bằng SDK JavaScript Application Insights (@microsoft/applicationinsights-web). Dùng cho Real User Monitoring (RUM) — lượt xem trang, nhấp chuột, phụ thuộc AJAX/fetch, ngoại lệ, sự kiện tùy chỉnh và dấu vết tác nhân GenAI phía trình duyệt tương quan với dấu vết OpenTelemetry phía backend. Bao gồm thiết lập SDK Loader Script và npm, tiện ích mở rộng framework (React, React Native, Angular), Click Analytics, trình khởi tạo telemetry và quy ước ngữ nghĩa OTel GenAI cho các span tác nhân/công cụ/mô hình phát ra từ trình duyệt.
devops
azure-ai-anomalydetector-java
microsoft
Xây dựng ứng dụng phát hiện bất thường với Azure AI Anomaly Detector SDK cho Java. Sử dụng khi triển khai phát hiện bất thường đơn biến/đa biến, phân tích chuỗi thời gian hoặc giám sát hỗ trợ AI.
development
azure-ai-language-conversations-py
microsoft
Triển khai Conversational Language Understanding (CLU) bằng SDK Python azure-ai-language-conversations. Sử dụng khi làm việc với ConversationAnalysisClient để phân tích ý định và thực thể trong hội thoại, xây dựng tính năng NLP, hoặc tích hợp hiểu ngôn ngữ vào ứng dụng.
development
azure-ai-ml-py
microsoft
Azure Machine Learning SDK v2 cho Python. Dùng cho không gian làm việc ML, công việc, mô hình, tập dữ liệu, tính toán và quy trình. Kích hoạt: "azure-ai-ml", "MLClient", "không gian làm việc", "đăng ký mô hình", "công việc đào tạo", "tập dữ liệu".
development