Azure / Azure/azure-cli

Approve a pipeline to run on a specific agent pool, avoiding to manually approve on the UI

Open
#28,111 2 comments 2 reactions 0 assignees View on GitHub
act-platform-engineering-squad Auto-Assign customer-reported DevOps feature-request Pipelines Service Attention
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

### Preconditions

- [X] No need to upgrade Python SDK or the Python SDK is ready.

### Related command

```bash
az pipelines run \
--commit-id "xxx" \
--name "xxx"
```

### Resource Provider

N/A

### Description of Feature or Work Requested

I'm automating integration testing with Azure DevOps Pipelines for on-premise agent containers. This requires me to create projects & pipelines, execute them, and confirm the result.

Each time a new pipeline is created, and a first run is programmed, the pipeline never runs and a message _"This pipeline needs permission to access a resource before this run can continue"_ is displayed. This requires a manual intervention on two buttons.

This behaviour disrupts a lot of the workflow. I would need a way to authorize a pipeline to run on a specific agent pool.

### Minimum API Version Required

N/A

### Swagger PR link / SDK link

N/A

### Request Example

_No response_

### Target Date

2023-03-01

### PM Contact

N/A

### Engineer Contact

N/A

### Additional context

In the Azure DevOps web interface, this call is executed: https://learn.microsoft.com/en-us/rest/api/azure/devops/approvalsandchecks/pipeline-permissions/update-pipeline-permisions-for-resource?view=azure-devops-rest-7.1&tabs=HTTP.

HTTP call:

```
PATCH
https://dev.azure.com/azure-pipelines-agent/a4830acb-f3a3-45b5-b555-d21a240eeb36/_apis/pipelines/pipelinePermissions/queue/80
Authorization: Bearer xxx
```

Request body:

```json
{
"resource": {
"type": "queue",
"id": "80"
},
"pipelines": [
{
"id": 9,
"authorized": true,
"authorizedBy": {
"displayName": "Clémence Lesné",
"id": "970e1056-90cc-66a2-aa4e-1b4b9efc4967",
"uniqueName": "clesne@microsoft.com",
"descriptor": "aad.OTcwZTEwNTYtOTBjYy03NmEyLWFhNGUtMWI0YjllZmM0OTY3"
},
"authorizedOn": "/Date(1703957638150)/"
}
]
}
```

Related:
- https://stackoverflow.com/questions/77040694/set-azure-devops-pipeline-permissions-via-api
- https://github.com/MicrosoftDocs/azure-devops-docs/issues/11660

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.