如何在具有特定 vcs 编号的 teamcity 中从 REST API 正确触发构建?

How to properly trigger build from the REST API in teamcity with a specific vcs number?

我正在开发一个 C# 工具来触发使用 TeamCity API 的 REST 构建。我想触发具有特定 vcs 编号的构建,所以这就是我正在做的:

POST => teamcity-server/httpAuth/app/rest/buildQueue 
HEADER => basicAuthCredentials
BODY => 

<build>
    <buildType id="SomeValidBuildId"/>
    <properties>
        <property name="SAMPLE_TEST" value="VERY_TESTY"/>
    </properties>
    <lastChanges>
        <change locator="version:4354174,buildType:(id:SomeValidBuildId)" />
    </lastChanges>
</build>

请求有效,构建具有我的属性和我指定的 vcs 编号。一切都很好,除非没有与该 vcs 编号关联的先前构建,请求失败并显示此错误消息:

Http request failed: 
error : Responding with error, status code: 404 (Not Found).
error : Details: jetbrains.buildServer.server.rest.errors.NotFoundException: Nothing is 
found by locator 'version:4354174,buildType:(id:SomeValidBuildId),count:1'.
error : Could not find the entity requested. Check the reference is correct and the user has permissions to access the entity.

构建可以访问 VcsRoot 设置及其所需的一切,如何触发自定义构建之前从未构建过的 vcs 编号?

当 TeamCity 尚未检测到已传递版本的更改时,您会收到错误响应,并且 so far TeamCity need to detect the change before it can be used in a build. You can configure commit/push hooks 让 TeamCity 在更改发生后立即知道或调用提交挂钩 URL在尝试触发构建之前。在接收提交挂钩请求和检测到更改之间仍然存在一些延迟(通常为几秒),因此等待一段时间然后才触发构建是有意义的。

这是针对 vcs perforce,运行 从 windows cmd 行卷曲,并允许我在给定的 p4 分支和更改列表上触发 TeamCity 构建

curl -u "teamcityUser:teamcityPassword" -X POST -d "{
""buildType"": {""id"": ""teamcityProjectId""},
""branchName"":""//p4/branch"",
""revisions"": {""revision"":[{
""version"":""59933"",
""vcsBranchName"":""//p4/branch""
}]}
}" --header "Content-Type: application/json" -H "Accept: application/json" <TeamCity Server host>:<port>/httpAuth/app/rest/buildQueue