Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compose git log for pending changes in TeamCIty

I have a TeamCity agent configured to build my XCode projects and I use github. I would like to automatically include in my release notes the descriptions from all pending commits in TeamCity.

How can I fetch them from github and store them in teamcity? Once I put them in a teamcity variable I can easily add them to my build script.

like image 297
mishod Avatar asked May 29 '12 06:05

mishod


1 Answers

THis is how I ended up doing this using a bash script:

#!/bin/bash 

curl -o lastBuild.tmp "http://localhost:8111/app/rest/buildTypes/id:bt2/builds/status:SUCCESS" --user rest:rest
last_commit=`xpath lastBuild.tmp  '/build/revisions/revision/@version'| awk -F"\"" '{print $2}'`

echo "##Last commit = $last_commit"
# prepare build notes
NOTES=`git log --pretty=format:"- %s" $last_commit..origin/master`

echo "this is it:$NOTES"

Some explanations:

  1. Use curl to fetch the last successful build from your build configuration. In my sample this is bt2, make sure to replace it with yours
  2. Use XPath/AWK to parse the XML response and get the last git version
  3. Use git log to get all changes form last build and format them anyway you want. I wanted to just get the commit descriptions.
like image 200
mishod Avatar answered Sep 28 '22 15:09

mishod