将 Artifact 传递给 Azure devops Rest api POST 方法

Pass Artifact to Azure devops Rest api POST method

我正在尝试使用 REST API 调用将工件从构建管道传递到发布管道。但是我找不到传递 artifact source 或 artifact name 的选项。我使用的json body 如下

{
  "definitionId": 1,
  "description": "test release",
  "artifacts": [
    {
    "alias": "Customer.CI",
    "instanceReference": {
     "id": "2",
     "name": null
     }
  }
 ],
 "isDraft": false,
 "reason": "none",
 "manualEnvironments": null
 }

另外 api 调用如下

    $Uri=https://vsrm.dev.azure.com/Orgname/ProjName/_apis/release/releases?api-version=5.1
    Invoke-RestMethod -Method Post -UseDefaultCredentials -ContentType application/json -Uri $Uri -Body $bodyString -Headers $header

如何在 POST API 发布管道调用期间的 运行 时间传递不同的工件

根据你调用的其余api,你应该想在创建发布时设置工件列表,那么工件应该能够在请求正文的"artifacts"中传递,作为您在问题中显示的 json 正文。

"alias"变量应该是你的构建定义名称"instanceReference"中的"id""name"变量指定工件源的 ID 和名称。也可以在web access中手动创建release时对比,如下图(Version应该是构建的“ID”):

如果我对这个问题有误解,请指出。