开发者

Mercurial automated deployment

I'm in the process of looking for a way to streamline the deployment of one of our php web applications (if it works on this I'll roll it out to other apps).

I quite like the l开发者_JAVA技巧ook of this: http://www.springloops.com/, but it's SVN and we're using mercurial.

Unfortunately we have no shell access to our current server, so something that works over ftp would be best, if anyone has any ideas?


You'll want to use mercurial's hg archive command from a hook. It takes a snapshot of the revision you indicate (via tag, etc.) and then exports it.

In your "production" repository's hgrc you could have something like this:

[hooks]
changegroup = ./doDeploy.sh

and then ./doDeploy.sh would have in it:

hg archive -r tip /tmp/deployme
ftp /tmp/deployme ftp://remoteserver

You'll end up having to work around all sorts of little glitches like file permissions, files that have been deleted from the repo but still exist on the server, etc. but in general that provides a good framework for a system that, upon having changes pushed to it by a release manager automatically uploads a snapshot to alive system.


That's my 5 cents: The ftp part of the answer only works for projects without subdirectories (FTP doesn't suports them) if you want to keep really all in sync here is my sh script (it uses LFTP, the -e option deletes files remotely that are no longer present locally):

#!/bin/sh
rm -rf /home/user/tmp/deploy/*
hg archive -r tip /home/user/tmp/deploy/
lftp -u username,password your.ftpsite.com << END_SCRIPT
set ftp:ssl-allow no
cd httpdocs/yoursite/
mirror -R -e --only-newer --log=/home/user/lftp.log /home/user/tmp/deploy .
END_SCRIPT
echo "#--- $(date)"  >> /home/user/lftp.log
exit 0


FTPExtension is working well for me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜