0
votes

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?

1
Why do you need the source code of the compiled application in order to test the compiled application?Daniel Mann
We need to rebuild the projects for a SonarQube analysis and we need to be sure the source code is from the same version as the binaries copied. Additionally, in case of our acceptance test builds, we want to be sure the same version of the source is used so that you are sure your tests run, meaning the source code version you expect. In case a developer right after you updated the test, you might get the newer version.Nico
@Nico For SonarQube analysis you can do that within same build, why to rebuild? And how can you make sure the changeset number with the latest successful build is the exact changeset your want to get? i mean if another build completed before you trigger your build. So, as my understanding, if you want to be sure the same version of the source is used, you just need to manually build with the specific changeset. (Quere build > Select the specific changeset)Andy Li-MSFT
Yes, but that requires me to do a manual schedule, or use another build definition that pull the drop location and associated changeset number. I dont want to manually schedule the build to set the changeset number. I want a powershell script to run before the Get to specify the changeset number. Does that make sense ?Nico

1 Answers

0
votes

We can not prevent the Get source step getting the latest sources, we can only add a Command Line/Batch script or PowerShell step to run script to get the specific changeset version sources. Then copy the specific source to build.

In you scenario, I think it doesn't make sense, as mentioned above, we cannot make sure the changeset number with the latest successful build is the exact changeset your want to get.

Seems the only way is build manually, specific the changeset to build.