如何使用工件解决发布管道部署问题?

时间:2020-03-05 09:48:48

标签: azure-devops azure-pipelines azure-pipelines-release-pipeline azure-devops-rest-api azure-repos

我正在使用Azure DevOps REST API创建发布管道并以编程方式进行部署。触发deploy API后,它将开始发布,但无法下载工件。在工件部分中,我已配置Azure Repos在代理中下载代码。我收到以下错误。

[错误1] TF401019:名称或标识符为21的Git存储库不存在,或者您没有操作权限 尝试。

数字21是我尝试完成此任务的次数。我不知道出了什么问题。

在创建发布时,我在请求正文中使用了以下详细信息。

"definitionId": String(release_definition_id),
"artifacts": [{
     "alias": releaseAlias,
     "instanceReference": {
         "definitionId": release_definition_id,
         "id": buildId,
         "sourceRepositoryId": azureRepoId,
         "sourceRepositoryType": "TfsGit",
         "sourceBranch": "master",
         "sourceVersion": azureRepoCommitId
      }
 }]

在创建发行版时,它没有指向正确的存储库ID。但是我在发行版本定义中提供了所有正确的细节。

1 个答案:

答案 0 :(得分:1)

尝试以下格式:

{
  "definitionId": 11,
  "artifacts": [
    {
      "alias": "_BSC",
      "instanceReference": {
        "sourceBranch": "master",
        "sourceRepositoryId": "ee63d8d0-xxx-0bc08b6712be",
        "sourceRepositoryType": "TfsGit",
        "id": "34a0883b8c-xxxxx-b46c03958b0"
      }
    }
  ]
}

关于以上定义的

要点

alias :如前所述,您在工件部分中设置了Azure Repos。这里的别名值应该是您的repos alias之一。例如,我的仓库名称是BSC,所以我的仓库别名是_BSC

id :将定义的sourceVersion更改为id。然后将commit id放在这里。