我无法从 azureCLI 任务触发 azure 管道构建
任务:
- task: AzureCLI@2
inputs:
azureSubscription: 'Free Trial(My subscription)'
scriptType: 'pscore'
scriptLocation: 'inlineScript'
inlineScript: |
az --version
echo "Running : az account show"
az account show
#export AZURE_DEVOPS_EXT_PAT='mypat'
$env:AZURE_DEVOPS_EXT_PAT='mypat'
az pipelines create --name newPipeline --org https://dev.azure.com/AbiNilOrg/ --project azure-devops-kubernetes-terraform --branch master
有错误的输出:
Running : az account show
{
"environmentName": "AzureCloud",
"homeTenantId": "***",
"id": "73c1af29-384c-4574-bd88-92d7bb392cfc",
"isDefault": true,
"managedByTenants": [],
"name": "Free Trial",
"state": "Enabled",
"tenantId": "***",
"user": {
"name": "***",
"type": "servicePrincipal"
}
}
WARNING: This command is in preview and under development. Reference and support
levels: https://aka.ms/CLI_refstatus
ERROR: The requested resource requires user authentication:
https://dev.azure.com/AbiNilOrg/azure-devops-kubernetes-
terraform/_apis/serviceendpoint/endpoints
##[error]Script failed with exit code: 1
据我所知,azure 无法形成正确的 URI 来到达休息点
ERROR: The requested resource requires user authentication:
https://dev.azure.com/AbiNilOrg/azure-devops-kubernetes-
terraform/_apis/serviceendpoint/endpoints
URI 的后缀 serviceendpoint/endpoints 不正确。
ADO 伙计们,如果对此有任何想法请帮忙!
提前致谢! 尼洛特帕尔
最佳答案
当您设置env:AZURE_DEVOPS_EXT_PAT
时,您仍然需要通过调用登录:
az devops login --organization https://dev.azure.com/contoso
因为:
If you have already signed in with az login interactively or using user name and password, then you don't have to provide a token as az devops commands now support sign in through az login. However, service principal log in via az login isn't supported, in which case a PAT token is required.
这里的任务是通过服务主体登录场景,您也可以在帐户显示中看到:
"user": {
"name": "***",
"type": "servicePrincipal"
}
有关更多详细信息,请查看文档 here
关于azure - 错误: The requested resource requires user authentication: in AzureCLI task build pipeline,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68334416/