Emmanuel
Emmanuel

Reputation: 3573

Getting List of Pipelines Authorized to Use an Environment

In the Azure DevOps user interface, one can edit the list of Pipelines that are authorized to use a Service Endpoint (aka Service Connection). This list can be retrieved from the API using:

GET https://dev.azure.com/{organization}/{project}/_apis/build/definitions/{id}/resources

which lists resources that the pipeline is authorized to use.

All I see in pipelines' resources are "endpoint"s (Service Connections) and "queue"s (Agent Pool, I guess). But not Environments. We absolutely have Environments that specific Pipelines are authorized to use.

How do I get this information using the Azure DevOps REST API?

Upvotes: 0

Views: 514

Answers (1)

tj-cappelletti
tj-cappelletti

Reputation: 1864

I'll admit, this is not very intuitive. I've done this a handful of times and it took me a bit to remember how exactly to do this. The documentation for this is under "Distributed Task".

The endpoint you are looking for is Pipeline Permissions - Get:

GET https://dev.azure.com/{organization}/{project}/_apis/pipelines/pipelinepermissions/{resourceType}/{resourceId}?api-version=7.0-preview.1

In your case, the resourceType should be environment and the resourceId should be the ID of the environment you want to query for.

To query for IDs of your environments, you will need to the use the Environments - List endpoint. Be careful with the term "environment" in Azure DevOps as there is a legacy "Release Environment" and the modern "Pipeline Environment". The link I put for the list environments endpoint is for the Pipeline Environments.

Upvotes: 1

Related Questions