TFS build definition associated commits

656 Views Asked by At

Can anyone help me get the list of git commits out of TFS 2013 that are associated with the build I'm currently creating?

Currently I'm doing

  • Build my azure cloud service
  • Use msbuild task to get version number
  • Update the version number in my nuspec
  • Use nuget.exe to pack into to a nuget package
  • Use nuget.exe to push up to the octopus server
  • Use octo.exe to create a release and deploy it to staging

What I'd also like to do is include the list of commits, that is already attached to the build definition summary page in TFS, to the release notes section of my nuspec so it gets include in the octopus release.

Anyone point me in the right direction?

Thanks!

EDIT

So let's tweak the question slightly, does anyone know how to get the GiT commit associated with the last build of a given build definition? It must be stored in TFS somewhere as that has to be the method it uses to produce its list.

If I can get hold of that then I can run

git log <last commit>^..HEAD --format="%ci - %cn - [%h](<path to my TFS>/commit/%H) %s%n" > rn.txt

which will allow me to then change my octo create-release command to

octo create-release --server=<server> --version=<version> --project=<proj> --apikey=<key> --releasenotefiles=rn.txt

And be happy :-)

EDIT 2 I'm using TFS not VSO so I can't access the REST API

1

There are 1 best solutions below

0
On BEST ANSWER

So I've likely been down voted as I could use git to do it all, but a comment pointing that out would've been nice.

Anyway,

As I'm brand new to git I missed the fact I can create a tag and use that in place of the commit id and then run up to the HEAD version to get all commits between them

git log <last tag>..HEAD --format="%ci - %cn - [%h](<path to my TFS>/commit/%H) %s%n" > rn.txt

works perfectly for my purposes.