azure - 跨项目共享 azure devops 变量

标签 azure azure-devops devops

我正在尝试跨项目共享链接变量。 我读到这是不可能的,但我发现这个 API 端点可以解决这个问题。 https://learn.microsoft.com/en-us/rest/api/azure/devops/distributedtask/variablegroups/share-variable-group?view=azure-devops-rest-6.0

当我调用这个API时: 补丁https://dev.azure.com/{organization}/_apis/distributedtask/variablegroups?variableGroupId={variableGroupId}&api-version=6.0-preview.2

有了这个 body :

{
"variableGroupProjectReferences":[
    {
        "description":"test1",
        "name":"test1",
        "projectReference":{
            "id":"50f7c113-de21-4e19-b910-b37ebffa984f",
            "name":"Customer Services"
        }
    }]
}

我收到这样的回复:

{
    "$id": "1",
    "innerException": null,
    "message": "Value cannot be null.\r\nParameter name: variableGroupProjectReferences",
    "typeName": "System.ArgumentNullException, mscorlib",
    "typeKey": "ArgumentNullException",
    "errorCode": 0,
    "eventId": 0
}

最佳答案

Value cannot be null.\r\nParameter name: variableGroupProjectReferences

请求正文似乎有问题。

您可以引用以下示例:

[
    {

    "variableGroupProjectReferences": 
    {
        "projectReference": {
        "id": "ProjectID",
        "name": "ProjectName"
        },
        "name": "variablegroupname",
        "description": ""
        }
 
   }
]

但是会显示错误:不允许共享变量组。

造成此问题的原因是变量组属性: "isShared": false

您可以使用Rest API获取变量组属性:Variablegroups - Get

但目前看来我们无法更改此属性。所以我们无法共享变量组。

引用此反馈票:VariableGroup cannot be shared via REST API .

建议您可以将问题反馈至Developer Community .

关于azure - 跨项目共享 azure devops 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72607640/

相关文章:

azure - 将 Azure SDK 和 Azure 存储版本升级到最新版本

sql-server - 发布到 SQL Azure 失败并显示 'Cannot drop the external data source' 消息

amazon-web-services - Elastic BeanStalk 应用程序部署后 Hook 未执行我的命令

postgresql - 在启动 docker 容器之前创建数据库

c# - Azure 服务总线主题架构

c# - 在 Azure Function Service Bus 触发器中使用异步方法

azure - 获取 TFS Webhook 订阅状态

azure - 在 ARM 模板中添加私有(private) nuget feed 的身份验证

azure - 适用于 Jenkins 的 Azure DevOps 和 Team Foundation Server 插件中的发布定义

将用户添加到存储库时触发 Github 操作