代码之家  ›  专栏  ›  技术社区  ›  divyanshm

从PowerShell更新VSTS发布定义时出错

  •  0
  • divyanshm  · 技术社区  · 8 年前

    here .修改变量并保存定义时,我从服务器得到的错误是 VS402982: Retention policy is not set for the environment 'environmentName'

    $c = Invoke-WebRequest 'https://accountname.vsrm.visualstudio.com/projectname/_apis/release/definitions/definitionId' -Method Get -Headers @{Authorization = 'Bearer ' + $authtoken} 
    $jsonObj = $c | ConvertFrom-Json
    $url3 = "https://accountname.vsrm.visualstudio.com/projectname/_apis/release/definitions/definitionId?api-version=4.1-preview.3";
    
    $contentType3 = "application/json"      
    $headers3 = @{
        Authorization = 'Bearer ' + $authtoken
    };
    
    $d = $jsonObj | ConvertTo-Json;
    Invoke-RestMethod -Method PUT -Uri $url3 -ContentType $contentType3 -Headers $headers3 -Body $d;
    

    这里可能有什么问题?

    1 回复  |  直到 8 年前
        1
  •  1
  •   divyanshm    8 年前

    如果你看到问题中提到的错误或者这个错误- VS402903: The specified value is not convertible to type ReleaseDefinition. Make sure it is convertible to type ReleaseDefinition and try again

    但是,在问题中提到的代码中, .请注意,发布定义具有多层嵌套对象、定义->环境->步骤/批准等,以及 这意味着您在调用VSTS API时缺少一些重要属性。修复方法是为 参数,以便在调用服务时不丢失任何属性。

    转换至JSON-深度100

    here .

    推荐文章