I have created an end-to-end CI/CD pipeline in Azure DevOps. I am trying to clone the original repository and create new pipelines using the Azure CLI(v1), using the below command:
az pipelines create --name {PIPELINE_NAME} --description {PIPELINE_DESCRIPTION} --repository {REPOSITORY_NAME} --branch {BRANCH_NAME} --repository-type {tfsgit} --project {PROJECT_NAME} --organization {ORGANIZATION_NAME} --yml-path {YAML_PATH} --service-connection {SERVICE_CONNECTION_NAME} --subscription {SUBCRIPTION_ID} --skip-first-run {true}
I am trying to execute the newly created pipeline using the below command:
az pipelines build queue --branch {BRANCH_NAME} --org {ORGANIZATION_NAME} --project {PROJECT_NAME} --definition-id {PIPELINE_ID} --subscription {SUBCRIPTION_ID}
The problem is, after executing the above commands, I always need to go to the Azure DevOps portal and manually authorize the pipeline to use the Service Connection. It shows a message like this in the portal This pipeline needs permission to access a resource before this run can continue
.
I am using this command to log in to the portal echo {PAT} | az devops login --organization {ORGANIZATION_NAME}
.
How can I avoid this problem of not going to the portal every time to authorize the pipeline to use the service connection? Is there a way I can do this using the CLI?
PS: All the above commands are executed using Python SubProcess.