2

I has plans to setup a SVN-server for testing purposes. Now is my question. How can i automatic deploy committed files to a path for my development/staging website?

I'ved leared that i can use a post-commit hook into SVN, but how can i configure this?

All of the committed files must be deployed in http://dev.staging.mywebsite.com in the path: /home/www/dev/staging/

And the repository is located in: /home/svn/mytestscript/

How can i do this?

Aar
  • 41
  • 1
  • 3
  • I think a post-commit hook for deploying a website is a bad idea even on a staging server. There are build tools specifically for deployment, I've only used Maven, but there are plenty of others out there such as Ant. – StuR Feb 28 '12 at 15:15
  • 1
    Bad idea or not, but do you have an idea for this? – Aar Feb 28 '12 at 15:31
  • You can try this link , i guess you would have to write a deployement script anyway : https://mikewest.org/2006/06/subversion-post-commit-hooks-101 – mpm Feb 28 '12 at 15:40
  • Please accept answers on your questions if they are the right solutions for you. This will give the deserved rep for the person who provided the correct solution and will also help you get more answers in your future questions. – Laurynas Tretjakovas Jul 08 '14 at 15:58

5 Answers5

9

Nicholas Ding: It's really a bad idea to write a post-commit hook for deployment.

Aar: And what are your reasons? It's not so bad to check your site, what you have committed? What are your arguments????

I have to agree with Nicholas Ding. The problem is that while you're doing your deployment via the post-commit hook, your developer is waiting for the commit to finish. If your deployment is taking only 30 seconds to complete, that's 30 seconds the developer is waiting for your post-commit hook to complete.

What do you think is going to happen if every time a developer commits a file, they have to wait 30 seconds for that commit to finish? What do you think they're going to think of Subversion, the development process in general, and you as the CM? Doing your deployment as a post-commit hook is not exactly a career enhancing move.


I suggest you look at Jenkins. Jenkins is what is called a Continuous Build System. You can set up Jenkins, so that every time a developer does a commit, Jenkins will do a build. This way, you're not tying up Subversion while your deployment is taking place.

The nice thing is that Jenkins can do your deployments too. And, if the deployment fails, it can email the developer who did the commit. Jenkins could even run some tests for you. For example, maybe your deployment worked, but the changed code results in an error. That might be nice to detect. And, you can store your deployable artifact in Jenkins in case you want to test it before deploying. If the testing works, You can go back to that build in Jenkins, click on a button, and do the deployment.

As another bonus, Jenkins allows your developers can see the history of all changes, builds, and deployments. It can also show you the history of all testing once you start testing. If you use an issue tracking system like Jira, Bugzilla, MantisBF, Track, or any number of other popular ones, Jenkins can integrate with those systems to help you track which build a particular issue was handled.

Even if you don't have to compile anything (let's say your entire webpage is just PHP files and JavaScripts), you can use Jenkins just for deployments and testing and still see a lot of benefit from it.

Jenkins is a great piece of software that can really improve your development process and handle your issue without slowing down Subversion. Plus, Jenkins is so easy to use, that it's probably quicker using Jenkins than figuring out how to do what you want in a post-commit hook anyway.

Community
  • 1
  • 1
David W.
  • 105,218
  • 39
  • 216
  • 337
  • You could get around the commit delay by having your hook fork off a deployment process, but of course you'd lose the ability to reject the commit if the deployment failed. I think using Jenkins is a much more robust and sensible solution. – TMN Feb 28 '12 at 20:37
1

A solution (from 2008) is at http://imrannazar.com/Automated-Deployment-with-Subversion which only deploys if the comment includes ~~DEPLOY~~. While this doesn't negate the issue @David W. mentioned, that time delay would be a deterrent to deploy with every commit. Good or Bad depends on the team and project!

0

Try Springloops it's auto deploy software. I use it and I thing it's great tool integrated with BamBam task management system. Check this out on http://www.springloops.io

0

It's really a bad idea to write a post-commit hook for deployment.

Better solutions are using tools like Capistrano (Ruby) or Fabric (Python).

  • And what are your reasons? It's not so bad to check your site, what you have committed? What are your arguments???? – Aar Feb 28 '12 at 17:51
  • Nicholas is correct. See my [response](http://stackoverflow.com/a/9489149/368630). – David W. Feb 28 '12 at 21:15
0
  1. svn diff --summarize in post-commit hooks. Details here

  2. Alternative choice 1 (bigger transfer, more time and outages) - svn export + remove all old data + copy exported tree

  3. Alternative choice 2 - staging site is additional WC, post-commit hook just initiate svn up on it

Community
  • 1
  • 1
Lazy Badger
  • 94,711
  • 9
  • 78
  • 110