How to know what build configuration triggered me, and read its properties
I have a build configuration (X) that's triggered by about 10 other build configurations. So, when any of those 10 builds run, X then runs after.
Within X, I'd like to know which build triggered me. I'd also like to read some of its build configuration properties. I know I can use the %dep.xxx.yyy% variable, but xxx is the configuration of the dependent build which could be one of many. Any way to do this?
Please sign in to leave a comment.
Hi Michael,
Normally, it would be your X build which triggers the other 10. If the 10 can run independently and X can run from all of them with different data, the best suggestion is to simply create X as a template and create a copy of X for each of the build configurations. That way, you are guaranteed to know this information before hand. Furthermore, if something goes wrong in X, you will know instantly which of the 10 original builds produced the failure, while with a single X you will need to dig deeper to find the issues.
There is a parameter, teamcity.build.triggeredBy, which includes a string with information on the trigger. From that information, you should be able to use the REST API to gather parameters or any other thing from the triggering build, but it will be a bit complex to do all of it, and while initially more cumbersome, separating the build in different builds should make it easier.
We went with the template approach. Seems to work fairly well! Thanks for your response..