Start TFS vNEXT (2015) build for a specific commit using GIT

Today I was trying to start a TFS build with a specified commit id using the "QUEUE NEW BUILD" windows of TFS vNext.

But when trying to do so TFS reports the following problem: "The value specified for SourceVersion is not va valid commit id"

 

After a lot of searching on the internet I found the problem dat TFS vNEXT uses the SHA1 version of the commit id. To get the SHA1 commit id you can execute the following command:

git rev-parse HEAD

This command returns the latest commit id on HEAD and returns this in the SHA1 format:

c7ab3fd13e30b55394afc3ebb5c73240c662b160

Using this SHA1 version of commit id in the TFS windows will start the Build for the specified commit. If you want to start a build for an older commit perform the following steps:

  1. Find the Commit id from TFS (ex: a9d8f7e7)
  2. Open the Command prompt and type 
    git rev-pars a9d8f7e7
  3. Output of the command should be something like: a9d8f7e76d24d5b4f1cc15378eb9513a6e2cdb4d
  4. Copy the SHA1 commit id
  5. Queue new build in TFS
  6. Past the output of the git command in the "Commit" textbox

Hopefully Microsoft will add some support for the smaller commit id's in the future, but for now this can be the workaround.

Update (Thanks to Travis and Artour)

There is a way to get the CommitID using Visual Studio. If you open the History from a branch and open de Commit Details of a commit you can press the 'Actions' link and choose 'Copy Commit ID'

If you are using SourceTree you see the full CommitId.

 

Happy coding ;-)