In a previous blog post I showed some very basic techniques for using Phing for doing deployment. As with any good deployment process, once you let people know that there is a flexible deployment tool other people start asking you to new things.
“Hey Chris, can you set things up so that whenever someone runs one of those deployment scripts, we send an email to our support mailbox of all the files that were pushed up since the last deploy?” After pausing for a minute to figure out how I would do it (the quick answer was “no idea”) I said “Sure, I’ll see what I can do.”
So I stood in front of my whiteboard and proceeded to sketch out an idea of how I would want to do such a thing. Luckily I could cheat and look at how Capistrano did it. Because the way that they do it makes so much sense, so I duplicated it quick-and-dirty style. A big thanks goes out to my friend Derek for pointing me in the right direction.
So, the way to make this happen is as follows:
- Read in a file inside your current deployment that contains the date of your last deployment
- Check your code out of your version control system into
/releases/ to /current
- Write a file into
/current that contains the date of the last deploy.
Here’s what it looks like as a Phing script
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
The key was figuring out the best way to send SVN log information via email. Leave it to the UNIX way of piping output to provide with the best solution totally within Phing.