we are running TFS 2015 Update 3 on premise.
We have a build definition that picks up the latest successful drop from the Gated checkin build to run tests. For theses tests we also need the source code of the same checkin. If we queue a new build it will get the latest sources, but its possible that these sources are of a different changeset than the last successful drop. Mainly because it can take about 2 minutes before the sources are pulled, if by then a new gated checkin has been completed, the task after the get will get a newer version of the drop than the sources that have been pulled.
Is there a way we can have the build run a script first, say the script that looks for the latest successful build. Then use the changeset number from that build to do the Get Sources of that specific changeset?