How to trigger a build where its dependencies use a different revision
It looks like this could possibly be done by first triggering the upstream build on some commit/branch and then using a build promotion to trigger the downstream build on a different commit/branch, but I don't think there is any build promotion REST API?
I've also tried triggering the build like this via curl, but it seems to ignore the snapshot dependencies. A build IS triggered, but not with this snapshot dependency, it uses one from the branch name.
```
curl -X POST -u "username:password" http://localhost:8111/app/rest/buildQueue --header "Content-Type: application/xml" -H "Accept: application/json" \
-d "
<build branchName=\"TRIGGERED_BUILD_BRANCH_NAME\">
<buildType id=\"TRIGGERED_BUILD_TYPE_ID\" />
<snapshot-dependencies>
<build locator=\"id:SNAPSHOT_BUILD_ID\">
<buildType id=\"SNAPSHOT_BUILD_TYPE_ID\" />
</build>
</snapshot-dependencies>
</build>
"
```
Perhaps by using a different vcsRoot for both builds (even though they use the same repository) I can somehow make the upstream build use a different commit/branch? Although I don't want it to use the default branch in the upstream dependency - I'd like to be able to specify the branch/commit for both the triggered build and a different one for it's upstream dependency.
Please sign in to leave a comment.
Promoting a build is just running a build on a specified revision, but it will run the full chain on that revision by default. If you want to trigger with a different revision, there's two ways of doing it:
-Using the dedicated feature introduced in 2019.1 by disabling "Enforce revision synchronization": https://www.jetbrains.com/help/teamcity/snapshot-dependencies.html. Please read this documentation carefully as it has some restrictions on how/when to use it.
-Disabling the Snapshot Dependency and triggering either via Finish Build Trigger or a REST API request (such as the one you are using in curl). Snapshot dependencies force revision synchronization otherwise, so the dependency needs to disappear if your scenario doesn't meet the requirements.
Could you try whether this would work for you?