I am developing a plugin that involves doing something after the last build of a build chain ends successfully. I have several build configurations with snapshot dependencies inside a project, and the next one runs automatically whenever the previous one is finished.
I am using the REST API route to retrieve snapshot dependencies (https://confluence.jetbrains.com/display/TCD10/REST+API#RESTAPI-Snapshotdependencies) and checking for the entire build chain whenever each build that's a part of it is finished, but I'm faced with a problem: The first build that runs, doesn't have any snapshot dependencies, so if I make the API call after the first build is finished, it won't return any meaningful results. Thusly, I won't know where it's placed in the build chain, and most importantly, if it's the last one.
One solution that I came up with was using the REST API, and each time a build ends, I would get its parent project, get every build from that project, and one by one get its snapshot dependencies to see if they depended on the build that had just finished. If no build had the present one on its snapshot dependencies, that would mean that it was the last build on the build chain. However that is slow and not very elegant.
Is there a simpler way, using either the REST API or the Java API, to know if a certain build is the last on the build chain? Or to get the entire build chain on a per-build basis? I'm open to anything.
Thank you in advance,