简体   繁体   English

从 azure devops 管道更新变量组

[英]update variable group from azure devops pipeline

I am trying to update a variable in a variable group using az pipelines cli from the pipeline, I have created a PAT and passed on to the pipeline its working fine.我正在尝试使用az pipelines cli 更新变量组中的变量,我创建了一个 PAT 并将其传递给管道,其工作正常。 but I use the default one such as $(System.AccessToken) its able to list the variable from the variable group but unable to update the variable group.但我使用默认值,例如$(System.AccessToken)它能够列出变量组中的变量但无法更新变量组。 Its saying它的说法

ERROR: You do not have permissions to perform this operation on the variable group.错误:您无权对变量组执行此操作。 A variable group Administrator should add you to the Administrator role.可变组管理员应将您添加到管理员角色。 ##[error]Script failed with exit code: 1 ##[错误]脚本失败,退出代码:1

after some search I found that I need to add Project Collection Build Service ( name ) as the administrator in the variable group and try again.经过一番搜索,我发现我需要在变量组中添加 Project Collection Build Service ( name ) 作为管理员,然后重试。 I have added that but still I am getting the same error.我已经添加了,但我仍然遇到同样的错误。 any suggestions?有什么建议?

I am using classic pipeline, here is the exported task from the pipeline.我使用的是经典管道,这是管道中导出的任务。

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)

This works well:这很好用:

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)

but you need to give Project Collection Build Service (account) Administrator permission on give variable group:但您需要授予Project Collection Build Service (account)管理员权限以授予变量组:

在此处输入图片说明

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM