2

Our Azure DevOps architecture uses a single release pipeline to upgrade and kick off other pipelines. Before the kicked pipelines run a release, the "kicker" pipeline updates the release definition of the "kickee" pipeline. I only have the name of the "kickee" pipeline, not the ID, so to get the pipeline to upgrade, we call the API documented at:

https://learn.microsoft.com/en-us/rest/api/azure/devops/release/Definitions/List?view=azure-devops-rest-5.0#releasedefinitionexpands

Because we need to modify several aspects of the release definition, I need to use the $expand parameter to expand a number of properties that will be updated (variables, artifacts, environments, etc). The documentation seems to indicate that multiple properties can be expanded, but it is unclear how to do this. Is this some list passed into the parameter, and if so, what separates each the list? Is it expected that the parameter is specified multiple times (which I guess is legal according to How to pass multiple parameters in a querystring)? Other options?

fepiv
  • 1,183
  • 1
  • 14
  • 25

2 Answers2

2

You separate the properties with ,.

For example:

https://vsrm.dev.azure.com/{your-account}/{your-project}/_apis/release/definitions?$expand=Environments,Artifacts&api-version=5.0-preview.3

You will get in the result the Environments and the Artifacts:

         "environments": [
            {
               "id": 1,
               "name": "Environment 1",
               "rank": 1,
               "owner": {
                  "displayName": "Shayki Abramczyk",
                  "url": "https://app.vssps.visualstudio.com/xxxxxxx-7cea-4070-bdad-0e1f6e0bc9e7/_apis/Identities/7a9a9b44-a2f1-6dfd-a7f6-e49cafde66b0",
                  "_links": {
                     "avatar": {
                        "href": "https://dev.azure.com/shaykia/_apis/GraphProfile/MemberAvatars/msa.xxxYTliNDQtYTJmMS03ZGZkLWE3ZjYtZTQ5Y2FmZGU2NmIw"
                     }
                  },
                  "id": "xxxxx-a2f1-6dfd-a7f6-e49cafde66b0",
                  "uniqueName": "xxxxx@gmail.com",
                  "imageUrl": "https://dev.azure.com/shaykia/_api/_common/identityImage?id=xxxxx-a2f1-6dfd-a7f6-e49cafde66b0",
                  "descriptor": "msa.N2E5YTliNDQtYTJmMS03ZGZkLWE3ZjYtZTQ5Y2FmZGU2NmIw"
               },
               "variableGroups": [],
               "schedules": [],
               "currentRelease": {
                  "id": 7,
                  "url": "https://vsrm.dev.azure.com/shaykia/xxxxx-b891-4fe5-b2fe-9b9a19a1d1af/_apis/Release/releases/7",
                  "_links": {}
               },
               "retentionPolicy": {
                  "daysToKeep": 30,
                  "releasesToKeep": 3,
                  "retainBuild": true
               },
               "properties": {},
               "preDeploymentGates": {
                  "id": 0,
                  "gatesOptions": null,
                  "gates": []
               },
               "postDeploymentGates": {
                  "id": 0,
                  "gatesOptions": null,
                  "gates": []
               },
               "environmentTriggers": [],
               "badgeUrl": "https://vsrm.dev.azure.com/shaykia/_apis/public/Release/badge/xxxxx5-b891-4fe5-b2fe-9b9a19a1d1af/1/1"
            }
         ],
         "artifacts": [
            {
               "sourceId": "xxxxx-b891-4fe5-b2fe-9b9a19a1d1af:2",
               "type": "Build",
               "alias": "MyProject",
               "definitionReference": {
                  "artifactSourceDefinitionUrl": {
                     "id": "https://dev.azure.com/shaykia/_permalink/_build/index?collectionId=xxxxxx-8c69-4ea0-8882-6340bf42f3b6&projectId=7fcdafd5-b891-4fe5-b2fe-9b9a19a1d1af&definitionId=2",
                     "name": ""
                  },
                  "defaultVersionBranch": {
                     "id": "",
                     "name": ""
                  },
                  "defaultVersionSpecific": {
                     "id": "",
                     "name": ""
                  },
                  "defaultVersionTags": {
                     "id": "",
                     "name": ""
                  },
                  "defaultVersionType": {
                     "id": "latestType",
                     "name": "Latest"
                  },
                  "definition": {
                     "id": "2",
                     "name": "MyBuild"
                  },
                  "project": {
                     "id": "xxxxxx-b891-4fe5-b2fe-9b9a19a1d1af",
                     "name": "SampleForVSTS"
                  }
               },
               "isPrimary": true,
               "isRetained": false
            }
         ],
         "releaseNameFormat": "Release-$(rev:r)",
         "retentionPolicy": {
            "daysToKeep": 30
         },
         "properties": {},
         "id": 1,
         "name": "New Release Definition",
         "path": "\\",
         "projectReference": null,
         "url": "https://vsrm.dev.azure.com/shaykia/xxxxxx-b891-4fe5-b2fe-9b9a19a1d1af/_apis/Release/definitions/1",
         "_links": {
            "self": {
               "href": "https://vsrm.dev.azure.com/shaykia/xxxxxx-b891-4fe5-b2fe-9b9a19a1d1af/_apis/Release/definitions/1"
            },
            "web": {
               "href": "https://dev.azure.com/shaykia/xxxxxx-b891-4fe5-b2fe-9b9a19a1d1af/_release?definitionId=1"
            }
         }
      }
   ]
}
Shayki Abramczyk
  • 36,824
  • 16
  • 89
  • 114
  • This answers the question much better than my workaround answer since it addresses a deficiency in the documentation. I have not tested this, so I am relying on the results posted to be accurate. Thanks for your updated answer! – fepiv Sep 27 '18 at 03:00
  • FTR, I did end up testing this and it works as expected. – fepiv Jun 04 '19 at 00:42
0

I worked around the problem by using the list API to get the definition ID and then called the get API to get the full contents of a particular release definition. This isn't ideal if I needed to update a large number of release definitions at once, but will work for my needs since I only need to update definitions one at a time.

fepiv
  • 1,183
  • 1
  • 14
  • 25
  • This answer ultimately was sufficient for our needs, but it's not the answer to the original question. Leaving because others might find this to be a sufficient way to address similar issues. – fepiv Sep 27 '18 at 03:01