Pushing from subversion to web server

2020-05-17 08:05发布

Long ago I tried to sort out my system between local, web server and subversion. I got some good explanation on this question.

Unfortunately I hit a road block on the whole pushing from SVN to a web server part and never revisited. All of my projects are solo, so I'm the only one developing them and often I'm the only user. So I've been able to get away with writing directly to the live server most of the time.

For 2009 I want to break that bad habit and actually do things the right way. I have SSH access to my web server (I can login and browse the files) but don't really know what to do in order to get the newest files out of SVN, into the server.

I've googled my fingers to the bone but everything I find requires some set of knowledge that I don't yet have.

I'd really, really appreciate step by step directions of how to automatically push the newest version of my code from an SVN repo to a live web server. FYI I'm currently using Beanstalk for Subversion hosting, but am totally willing to change that if someone has a better suggestion.

Thanks

7条回答
Juvenile、少年°
2楼-- · 2020-05-17 08:41

If you have SSH access you could do:

svn export [url to repo] [web directory]

Export will mean you don't get the .svn baggage that comes with a working copy.

查看更多
爱情/是我丢掉的垃圾
3楼-- · 2020-05-17 08:50

Release Management

you can create an job/batch which exports the svn to a local folder. after the export you can upload it with rsync.

the job can automatically execute by the svn hooks.

you can also use mtod ways but keep in mind: using a checkout on the server is a security risk, if someone can access the .svn folders! they can access the php code and see passwords or bugs.

查看更多
Ridiculous、
4楼-- · 2020-05-17 08:56

simply - login to your server machine and checkout the repository contents. This should be done just once.

$ svn checkout [http|svn|whatever_you_got_there]://{your_svn_repo} {checkout_directory}

Everytime you need to update your working copy with the newest one, perform update:

$ cd {checkout_directory}
$ svn update
查看更多
闹够了就滚
5楼-- · 2020-05-17 09:02

Unless your hosting company has given you access to either cron(1) or a shell, it will be difficult as svn, a centralised VCS, does not have a way to push things to a working directory, you are supposed to svn update.

Several ways to do what you want, depending on the above mentioned resources available:

  1. define a crontab(5) entry that does cd $WEBSITE && svn update
  2. use ssh to connect to your website and do the same command. The ssh can be automated by a crontab entry on your side.
  3. have a special cgi on your website, hopefully protected by password, that could be run periodically (from cron on your side) that does the same command.

Best way to me will still be moving to a decentralized VCS (like Mercurial or git) but that is a much bigger project.

查看更多
倾城 Initia
6楼-- · 2020-05-17 09:03

I had a somewhat similar question some time ago, however I didn't have SSH access into my server so I was quite limited in my options.

Depending on the size of your project you might consider not doing an export. In my case the project was over a gig of data! Not practical because with an export you need to export all the files over and over again. If you only have a hand full of files it might be different. Also, doing an export on your local machine means that the export needs to download the file first and then upload it to your hosting which is like a waste of bandwidth.

Also keep in mind that doing an SVN export doesn't do any database updates. E.g., while you're developing your site your database will probably change may times. With just an SVN export you still need to manually re-import the database on the server.

What I suggest is that you write a script that you place on the server. You can make this script as elaborate as you want of course but the bare bone script would do an 'update' on a checked out version of your site, does an export of your database in a temp folder (your database is of course also placed under version control) and re-imports the database (or merges it, whatever it needs to do). With one single command you can then deploy your site. Over and over and over again.

There are tools that can help you with this sort of automation, like CruiseControl and Capistrano.

查看更多
We Are One
7楼-- · 2020-05-17 09:05

have you tried using our FTP deploy on Beanstalk? We also have web-hooks available, which means you can ping a URL on each commit to code your own stuff.

http://help.beanstalkapp.com/articles/17-deployment-and-releases

查看更多
登录 后发表回答