Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automating svn update

I'm frequently sshing into a server, switching to a specific directory and running svn-update

I'm thinking that there's probably a very easy way to automate this, so I can simple specific a subdirectory when I run the script and it'll login via SSH, cd to the right directory and run svn-update.

Is this a job for capistrano or could a simple bash script do the job?

like image 203
Tom Avatar asked Jul 30 '09 08:07

Tom


People also ask

How do I pull latest changes in svn?

Simply type svn update [name-of-directory] , or cd to that directory and type svn update there. Show activity on this post.

What is svn update command?

Description. svn update brings changes from the repository into your working copy. If no revision is given, it brings your working copy up to date with the HEAD revision. Otherwise, it synchronizes the working copy to the revision given by the --revision ( -r ) option.

Will svn update overwrite my changes?

When you update, the contents of your working copy are updated with all of the changes that have been committed to the repository since you last updated. Subversion is pretty smart about updating and never just overwrites files that have local changes with copies from the repository.

What is the svn that integrates with Jenkins?

The Jenkins Subversion plugin uses SvnKit as the subversion client and doesn't require a native client to be available on the host. Setting up a CI server with Jenkins and Subversion is limited to a very minimal installation process: just run the Jenkins WAR and you're done.


2 Answers

Sounds like a job for cron. Execute crontab, and add an entry like so:

#min hour date month day command
 0   *    *    *     *   ssh user@host '(cd path/to/working/copy; svn update)' 

You may need to set up ssh passwordless authentication with ssh-agent so that it won't prompt.

EDIT (per comments below):

Assuming you have sufficient privileges to do so, run

ssh user@host crontab -e

Then add an entry like so:

#min hour date month day command
 0   *    *    *     *   (cd path/to/working/copy; svn update)

You can ignore the part above the edit, unless your server doesn't allow you to use cron.

like image 108
Michael Aaron Safyan Avatar answered Sep 28 '22 09:09

Michael Aaron Safyan


Perhaps you should ask yourself why you are performing this action?

Could a build server such as CruiseControl or Hudson solve the more general case (of knowing when a svn commit has been performed)?

If you need monitoring on a specific svn server, and you have administration access to it, you can enable a post-commit hook to the server, for instance to send you an email on every commit (or only on some specific types of commits).

It would help, if you could clarify the usecase of your situation.

like image 40
Steen Avatar answered Sep 28 '22 09:09

Steen