0
votes

I am trying to pass artifact from build pipeline to release pipeline using REST API call. But I couldn't find an option to pass the artifact source or artifact name . The json body i am using is given below

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

ALso the rest api call is as below

    $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

How to pass different artifact at run time during the POST API call of the release pipeline

1

1 Answers

1
votes

According to the rest api you call, you should want to set the artifact list when creating the release, then the artifacts should be able to be passed in the "artifacts" of the request body, as the json body you showed in the question.

The "alias" variable should be your build definition name, The "id" and "name" variables in the "instanceReference" specify the ID and name of the artifact source. You can also compare it when creating the release manually in web access, as shown below (The Version should be the “ID” of the build):

enter image description here enter image description here

If I misunderstand this issue , please point it out.