获取授权使用环境的管道列表。

huangapple go评论64阅读模式
英文:

Getting List of Pipelines Authorized to Use an Environment

问题

在Azure DevOps用户界面中,可以编辑授权使用服务端点(也称为服务连接)的管道列表。可以使用以下API检索此列表:

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

该API列出了管道被授权使用的资源。

在管道资源中,我只看到“endpoint”(服务连接)和“queue”(代理池,我猜是代理池)的内容,但没有“Environments”(环境)。我们确实有特定管道被授权使用的环境。

如何使用Azure DevOps REST API获取此信息?

英文:

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?

答案1

得分: 1

代码部分不需要翻译,以下是翻译好的部分:

"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 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."

英文:

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.

huangapple
  • 本文由 发表于 2023年2月7日 04:02:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/75366022.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定