我有一个问题,我使用 CLI 工具自动执行了很多任务
az boards work-item relation show
az boards work-item show
az boards work-item update
但现在,我的疑问是,作为自动化的一部分,我需要上传一些工作项的附件,可以使用 CLI 来做到这一点吗?
搜索我发现了这个链接:
https://learn.microsoft.com/en-us/rest/api/azure/devops/wit/attachments/create?view=azure-devops-rest-7.0&tabs=HTTP#upload-a-text-file
但是我没有看到在哪里指定要上传文件的工作项 ID,有人遇到这种需要吗?
谢谢您,最诚挚的问候。
最佳答案
But I do not see where specify the work item ID where you want to upload the file, somebody face by this need?
是的,您可以分两步上传特定工作项目中的附件 -
首先使用以下 URL 创建附件文件
POST https://dev.azure.com/{organization}/{project}/_apis/wit/attachments?fileName=textAsFileAttachment.txt&api-version=7.0
这里的请求正文是“要上传的用户文本内容”
第二次使用以下 URL 将此附件添加到特定工作项
PATCH https://{instance}/{collection}/{project}/_apis/wit/workitems/{id}?api-version=5.0
请求正文-
在下面的请求正文中使用上面生成的 URL
[
{
"op": "add",
"path": "/relations/-",
"value": {
"rel": "AttachedFile",
"url": "https://dev.azure.com/{collection}/yyyyyyyy/_apis/wit/attachments/xxxxxxxxxxx?fileName=textAsFileAttachment.txt",
"attributes": {
"comment": "Spec for the work"
}
}
}
]
通过这种方式,您可以将附件上传到工作项。
关于AZURE:通过 az board 工作项上传附件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76921939/