Search code examples
version-controlteamcitytfvcbuild-definition

TFS Build definition - See included changesets before build


I have TFS 2017 build definition with TFVC repository path set. With TeamCity you could see new changesets added to the branch this build definition is linked to since the last successful build.

How can I do that in TFS 2017 build?


Solution

  • No such a built-in feature in TFS. We can only see the Associated changes from the build summary after completing the build.

    However generally you can follow below steps to see which changesets will be included before build:

    1. Get the source version(changeset number) from last successful build with the REST API:

      GET http://SERVER:8080/tfs/DefaultCollection/{Project}/_apis/build/builds/{Build ID}
      

    e.g Enter the URL in brower -> Enter -> Ctrl + F -> Find the string : source version (Reference below screenshot)

    1. Then get the changesets from the specific branch/path which the build definition is linked to (branch $/LCScrum/1/PS for example here):

      GET http://SERVER:8080/tfs/DefaultCollection/_apis/tfvc/items?scopePath=$/LCScrum/1/PS&recursionLevel=OneLevel&api-version=1.0-preview.1
      

    From the second response we can get the latest version of files (changesets) in the specifc branch/path. Then you can compare the two responses, the changesets with the number which is larger than the source version of the last successful build will be included in next build.

    Ofcourse you can also get the information and compare directly via the web portal.

    enter image description here