Search code examples
buildazure-devopsbuild-definition

Unable to save/modify imported build definition in VSTS


I am attempting to export a build from one project to another. Projects are in different collections. I have collection admin so perms should be good, but just to be sure I granted myself build and project admin.

I exported the build as json using the VSTS UI in the source project then imported in the target project. All the tasks are present, but the parameters are grayed out. I also cannot enable/disable tasks. There are some parameters that need to be filled in such as build agent. I was able to select the appropriate agent. I have no outstanding items at this point that the UI is indicating I would need to address prior to saving. The save, discard, queue options are all grayed out.

I can add a new phase, but I can't add any tasks to that phase. I also tried bringing up the yaml and compared it to the yaml in the source project, no differences.

Why can't I save my imported build definition?


Solution

  • Import succeeded after replacing all instances of the project and collection ids in the json I was attempting to import. At the time of this post those changes must be completed manually.

    UPDATE:

    I tried just removing the offending properties rather than replacing them and that worked. I created a simple script to clear out those properties:

    Param(
    [parameter(Mandatory=$true)]
    [alias("p")]
    $path
    )
    
    $removeProperties = @("triggers","metrics","_links","authoredBy","queue","project")
    $json = Get-Content -Path $path -Raw | ConvertFrom-Json
    
    foreach ($property in $removeProperties) {
      $json.PSObject.Properties.Remove($property)
    }
    
    $json | ConvertTo-Json -Depth 100 | Set-Content -Path $path -Force