关于 azure-devops
供处理 Azure DevOps 任务的 Agent 使用的技能。优先采用环境中可用的 Azure DevOps MCP 工具,并在不可用时提供 PAT API 操作指引,同时说明推送和拉取请求的限制。
主要功能
- 01优先选择 MCP 工具
- 02使用 PAT 进行 API 身份验证
- 03列出常用 Git API 端点
- 04指导分支与拉取请求操作
适用场景
- 01列出 Azure DevOps 仓库
- 02创建或更新拉取请求
- 03将用户要求的更改推送到分支
MCP 相关
优先使用环境中可用的 Azure DevOps MCP 工具;否则提供直接访问 Azure DevOps API 的说明。
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ openhands/ extensions --skill azure-devops安装后在 Claude Code 中输入/azure-devops确认已加载。
附带文件.plugin/plugin.jsonREADME.md
详细介绍
连接方式选择
如果 Agent 环境中有经过身份验证的 Azure DevOps MCP 工具,请优先使用。通过检查工具是否可用来判断,不要依赖特定的 MCP 服务名称。仅当 Azure DevOps MCP 工具不可用,或明确需要使用原始 API 或 curl 时,才使用下方的令牌和直接 API 说明。
你可以使用环境变量 AZURE_DEVOPS_TOKEN 与 Azure DevOps API 交互。
如果向 Azure DevOps 推送时遇到身份验证问题(例如出现密码提示或权限错误),旧令牌可能已过期。此时,请更新远程 URL,将当前令牌加入其中:git remote set-url origin https://${AZURE_DEVOPS_TOKEN}@dev.azure.com/organization/project/_git/repository
以下是推送说明,但仅在用户要求时执行:
- 切勿直接推送到
main或master分支 - Git 配置(用户名和电子邮件)已预先设置。不要修改。
- 你可能已处于以
openhands-workspace开头的分支上。推送前请创建一个名称更合适的新分支。 - 创建自己的分支或拉取请求后,继续更新该分支或拉取请求。除非用户明确要求,否则不要新建。根据需要更新拉取请求的标题和描述,但不要更改分支名称。
- 除非用户另有要求,否则以主分支为基础分支
- 创建或更新拉取请求后,向用户发送一条简短消息,并附上拉取请求链接。
- 除非用户明确要求,否则不要将拉取请求标记为可供审核
- 尽可能少地执行步骤。例如,你可以通过运行以下 bash 命令,一步推送更改:
git remote -v && git branch # to find the current org, repo and branch
git checkout -b create-widget && git add . && git commit -m "Create widget" && git push -u origin create-widget
在 Windows PowerShell 中,如果已安装的 shell 不支持 &&,请将这些 git 命令分别运行。
Azure DevOps API 用法
使用 Azure DevOps API 时,需要通过个人访问令牌(PAT)进行 Basic 身份验证。用户名会被忽略(留空),密码为 PAT。
以下是使用 curl 进行身份验证的方法:
# Convert PAT to base64
AUTH=$(echo -n ":$AZURE_DEVOPS_TOKEN" | base64)
# Make API call
curl -H "Authorization: Basic $AUTH" -H "Content-Type: application/json" https://dev.azure.com/{organization}/{project}/_apis/git/repositories?api-version=7.1
PAT 标头的 PowerShell 等效写法:
$auth = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$env:AZURE_DEVOPS_TOKEN"))
Invoke-RestMethod `
-Headers @{ Authorization = "Basic $auth"; "Content-Type" = "application/json" } `
-Uri "https://dev.azure.com/{organization}/{project}/_apis/git/repositories?api-version=7.1"
常用 API 端点:
- 列出仓库:
https://dev.azure.com/{organization}/{project}/_apis/git/repositories?api-version=7.1 - 获取仓库详情:
https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}?api-version=7.1 - 列出拉取请求:
https://dev.azure.com/{organization}/{project}/_apis/git/pullrequests?api-version=7.1 - 创建拉取请求:
https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/pullrequests?api-version=7.1(POST)