I'm trying to run a TeamCity build via the REST API using a particular git commit. Creating a new build via the API requires a TeamCity modification ID, not a git commit reference.
How can I convert a git commit to a TeamCity modification ID? The closest I've found so far is calling /app/rest/changes?fields=change:(version,webUrl)
, which returns a list of <change />
nodes and then parsing the modId from the webUrl property, but I'm not sure how to filter this via TeamCity locators to only contain the particular commit I need.
I discovered this can be achieved by calling the endpoint like this: /httpAuth/app/rest/changes?locator=version:<version>&fields=change:(version,id)
.
This will return a changes array, containing a single changeset - the version
key will match the VCS version you filter on, and the id
key will be TeamCitys modification ID, which can then be fed into a further calls to queue builds with particular changesets, etc.