how to install svn post-commit hook
I am running SVN on Linux. I was hoping to run auto deployment once committed. Based on开发者_如何学Python my searching, it looks like svn post-commit might do the trick. But I couldn't find SVN post-commit from my SVN installation. So I wonder if it's a separate install? Is there any SVN post-commit hook that I can download and install?
First, you probably don't want to do this as a post-commit. The reason is that you don't want to do anything that takes too long to do in a hook because the user has to wait for the hook to complete before they can continue.
To answer your question, take a look at the repository directory on your server, you should see the following directories and files:
- README.txt
- conf
- db
- format
- hooks
- locks
One of the directories is called hooks
. Take a look in this directory:
- post-commit.tmpl
- post-lock.tmpl
- post-revprop-change.tmpl
- post-unlock.tmpl
- pre-commit.tmpl
- pre-lock.tmpl
- pre-revprop-change.tmpl
- pre-unlock.tmpl
- start-commit.tmpl
These are templates for the various hooks. You'll see these are all simple BASH/Korn/Bourne shell scripts. You'll be using the svnlook
command to get information about the revision or transaction (if pre-commit hook) that your user just committed.
What you would do is run the command svnlook changed
to see what was changed, then based upon this information, you'll have to fetch the file, and deploy it. This means you'll have to create a working directory and do a checkout. Imagine a developer doing a checkin, and then waiting for your post-commit hook to do a checkout and deployment.
What you would be better off doing is getting something like Jenkins to do your post commit tasks. Jenkins is normally a continuous build server. Whenever someone does a commit, Jenkins does a checkout on that project and does the build. It can run all sorts of tests, and then email the developers if there are any problems.
However, it can also simply do a checkout and deployment if you really have nothing to build. Jenkins uses Java 1.6 to run, but otherwise, it's pretty easy to install and use. It's all menu driven, and you don't need to know how to create XML files or write any programs to use it.
So, take a look at Jenkins and see about doing your deployments from there. This way, your developers can continue their work while Jenkins handles the deployments. And, you can have Jenkins send out an email, an IM, Tweet, or even change a traffic light from green to red if there is an issue with the deployment.
It's not a separate install. In your respository directory, there is a 'hooks' dir. You can find post-commit.tmpl, just modify the file and rename it to executable file according your os type.
精彩评论