首页 > 解决方案 > 在 VSTS API 中排队 yaml 构建导致无法解决参考错误

问题描述

我正在使用 PowerShell 在 VSTS 中对 yaml 构建定义进行排队,看起来我没有为 VSTS API 调用提供正确的 JSON 正文:

$uri = "https://$($accountName).visualstudio.com/$($projectName)/_apis/build/builds?api-version=4.1" 

$body = @{
    "definition" = @{
        "id" = "$($buildDefinitionId)"
        "sourceBranch" = "refs/heads/master"
    }
}

这是错误消息:

"error","message":"Unable to resolve the 
reference '' to a specific version. Verify the reference exists in the source repository.

我可以确认项目中存在 YAML 构建定义。我查看了一个类似提交的 GitHub 问题,但似乎没有帮助。有任何想法吗?

标签: azure-devops

解决方案


改用此代码:

$body = @{
    "definition" = @{
        "id" = "$($buildDefinitionId)"; 
    };
    "sourceBranch" = "refs/heads/master";
}

推荐阅读