REST API: why was a build triggered?

I have a relatively deep build structure and want to find out why a top level build was run. I'm writting a little script that will create a log of changes.

Each of the builds as a number of dependencies and a 'successful build' trigger on those dependencies.

So when my top level build runs (or any build somewhere in the middle), it could be because of a VCS or dependency change.

As far as I've been able to figure out, I can look at the <changes> element and see if there were changes that caused the build to run.

But if this is zero, then it could have been because of an dependent build was re-run, or a schedule trigger fired. I don't know which.

The <changes> element tells me what changed in the attached VCS.

But <artifact-dependencies> doesn't tell me if any of the dependencies changed - just that these specific dependencies were used to generate the current build.

If <changes> was zero, then it must have been an <artifact-dependencies> that changed. But, which one(s)?

How can I tell what caused a build to trigger?

Thank you!

3 comments
Comment actions Permalink

Hi Stephen,

You can find this information in details for the build. For example:
http://localhost:8111/httpAuth/app/rest/builds/id:<buildId>

The answer is:
<triggered type="unknown" details="remote-run-on-branch" date="20150109T193557+0400"/>

Also this information is stored in teamcity.build.triggeredBy parameter.

0
Comment actions Permalink

Thank you for your response!

In a build/id:build-number response, I see the <triggered> element; but only a date field; and that is with a <changes> element that says 1 change (note: the build has a VCS trigger set on it).

<triggered date="20150113T111436-0500"/>
<changes count="1" href="/guestAuth/app/rest/changes?locator=build:(id:20426)"/>


Also, if I look at the specific build in the web interface, I don't see the parameter you describe in the Build Parameters tab.

Is this specific to a given TC version (I'm running 8.0.5)? Or should I expect to see this in 8.0.5?
0
Comment actions Permalink

This parameter was added in TeamCity 8.1. I would recommend you to upgrade to the latest TeamCity version (9.0.1 as of now).

0

Please sign in to leave a comment.