I'm using Phing to do post build tasks in Hudson.
I want to generate changelog containing all commits since last successful Hudson build. But looks like neither Hudson nor Git plugin for Hudson does not provide %last_build_time%
variable.
This would be satisfying solution, (but how to get the time?):
git log --pretty="%s" --since="%last_build_time%"
The only way I see for now is extracting it from the job xml file, but I do not know if it is possible with Phing.
How do you generate your change logs?
I have extracted last successful build date using bash:
(In xml file I had to replace
"
with"e;
entity).@takeshin's answer is fine if you have access to the build.xml file, but this may break, especially if you are building on a slave node (since the slave does not have the referenced build.xml).
Fear not, since you can access this information via Jenkins directly, using its remote access api:
https://wiki.jenkins-ci.org/display/JENKINS/Remote+access+API
For example:
(will give you the xml content... you could replace xml with json to get json content back instead of XML, for example).
NOTE that you may need to use authentication if you've setup your Jenkins instance to require it. Again, fear not: https://wiki.jenkins-ci.org/display/JENKINS/Authenticating+scripted+clients
Then it's a simple matter of parsing the XML for what you want. Something like this, perhaps:
So, pulling it all together, you can end up with a (relatively) simple shell script to retrieve the last good revision hash from Jenkins:
Cheers,
Levi