【问题标题】:Create Azure Devops environment from script从脚本创建 Azure Devops 环境
【发布时间】:2020-06-12 17:30:09
【问题描述】:

我想从 Powershell 创建一个 Azure DevOps 管道环境。

但是,使用 Azure CLI 或 Azure REST API,我找不到任何相关信息。 版本中有一些关于环境的概念,但这不是我需要的。

使用门户时,以下 URL 称为“/_apis/distributedtask/environments”,但找不到有关此 REST API 端点的任何信息。

有人知道如何自动化吗?

【问题讨论】:

    标签: azure azure-devops azure-devops-rest-api azure-cli


    【解决方案1】:

    你是对的,如果我在创建新环境时检查网络部分,我可以看到它使用了这个 api:

    https://dev.azure.com/{org}/{project}/_apis/distributedtask/environments
    

    使用此 JSON 正文:

    {
        "description":"",
        "name":"test"
    }
    

    我没有看到它 domunetd 但它应该可以工作:)

    【讨论】:

    • 运行此代码:$uriAccount = $BaseUri + "distributedtask/environments?api-version=5.1-preview" $body = "@{description=""a"";name=""b ""}" | ConvertTo-Json Invoke-RestMethod -Uri $uriAccount -Method Post -Body $body -ContentType "application/json" -Headers $azureDevOpsAuthenicationHeader Invoke-RestMethod : {"$id":"1","innerException":null,"message ":"TF400898: 发生内部错误。活动 ID: 5e...","typeName":"System.NullReferenceException, mscorlib","typeKey":"NullReferenceException","errorCode":0,"eventId":0 }
    • 好的,现在修复了,我的身体错了,它适用于 $body = @{"description"="a";"name"="b"} | ConvertTo-Json
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-22
    • 2020-04-02
    • 2022-10-17
    • 2022-09-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多