cod*_*bot 1 azure azure-cli azure-devops azure-pipelines azure-pipelines-yaml
我正在尝试使用az pipelines管道中的 cli 更新变量组中的变量,我创建了一个 PAT 并将其传递到管道,其工作正常。但我使用默认的,例如$(System.AccessToken)它能够列出变量组中的变量,但无法更新变量组。其曰
错误:您无权对变量组执行此操作。变量组管理员应将您添加到管理员角色。##[错误]脚本失败,退出代码:1
经过一番搜索,我发现我需要将 Project Collection Build Service ( name ) 添加为变量组中的管理员,然后重试。我已经添加了这一点,但我仍然遇到同样的错误。有什么建议么?
我使用的是经典管道,这是从管道导出的任务。
steps
- task: AzureCLI@2
displayName: 'Azure CLI '
inputs:
azureSubscription: 'sc'
scriptType: pscore
scriptLocation: inlineScript
inlineScript: |
az extension add --name azure-devops
az pipelines variable-group variable list --group-id id --org "orgname" --project "projectname"
az pipelines variable-group variable update --group-id id --name apim-service-name --value $(str_tf_module_containername) --org "orgname" --project "projectname"
env:
AZURE_DEVOPS_EXT_PAT: $(System.AccessToken)
Run Code Online (Sandbox Code Playgroud)
这效果很好:
steps
- pwsh: |
az extension add --name azure-devops
az pipelines variable-group variable list --group-id id --org "orgname" --project "projectname"
az pipelines variable-group variable update --group-id id --name apim-service-name --value $(str_tf_module_containername) --org "orgname" --project "projectname"
env:
AZURE_DEVOPS_EXT_PAT: $(System.AccessToken)
Run Code Online (Sandbox Code Playgroud)
但您需要授予Project Collection Build Service (account)管理员对给定变量组的权限:
| 归档时间: |
|
| 查看次数: |
3226 次 |
| 最近记录: |