Difference between revisions of "SVN server installation (Linux)"

Line 1: Line 1:
Subversion is used to managed file revisions, branches and application releases.
+
SVN is used to managed file revisions, branches and application releases.
 
You have to install a SVN server, then a client on each remote computer.
 
You have to install a SVN server, then a client on each remote computer.
 
  
  
 
=SVN server=
 
=SVN server=
  
 +
==Linux (subversion)==
  
==installation==
+
===installation===
 
Required package
 
Required package
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
Line 19: Line 19:
 
mkdir /var/svn/myRepository
 
mkdir /var/svn/myRepository
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 
Set rights
 
Set rights
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
Line 27: Line 28:
  
  
==Server automatic startup==
+
===Server automatic startup===
  
  
===Create SVN startup script===
+
====Create SVN startup script====
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
vim /etc/init.d/svnServer  
 
vim /etc/init.d/svnServer  
Line 81: Line 82:
  
  
===Update boot sequence===
+
====Update boot sequence====
 
Create symlink
 
Create symlink
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
Line 94: Line 95:
  
  
==Start SVN server==
+
===Start SVN server===
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
/etc/init.d/svnServer start
 
/etc/init.d/svnServer start
Line 100: Line 101:
  
  
==How to remove SVN from boot?==
+
===How to remove SVN from boot?===
 
Just execute the following sequence
 
Just execute the following sequence
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
Line 108: Line 109:
  
  
==SVN repository==
+
===SVN repository===
 
To do any advanced task, you've to use "svnadmin"
 
To do any advanced task, you've to use "svnadmin"
 
To create repository you have to:
 
To create repository you have to:
Line 116: Line 117:
  
  
===1. Create root folder===
+
====1. Create root folder====
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
svnadmin create /var/svn/myRepo
 
svnadmin create /var/svn/myRepo
Line 131: Line 132:
  
  
===2. Adjust rights===
+
====2. Adjust rights====
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
vim /var/svn/myRepo/conf/svnserve.conf
 
vim /var/svn/myRepo/conf/svnserve.conf
Line 144: Line 145:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
===3. Create users===
+
====3. Create users====
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
vim /var/svn/myRepo/conf/passwd
 
vim /var/svn/myRepo/conf/passwd
Line 152: Line 153:
  
  
===Repository access===
+
====Repository access====
 
You can use the repository with the following SVN URL: svn://server/''java''  
 
You can use the repository with the following SVN URL: svn://server/''java''  
  
  
==LDAP + WebSVN access==
+
===LDAP + WebSVN access===
 
Instead of “svn://” + dedicated SVN user you can use “https://myServer/dav_svn/” + LDAP user.
 
Instead of “svn://” + dedicated SVN user you can use “https://myServer/dav_svn/” + LDAP user.
 
Please read the Apache 2 documentation to get more information.
 
Please read the Apache 2 documentation to get more information.
  
 
>> TODO : add link <<
 
>> TODO : add link <<
 +
 +
 +
 +
==Windows==
 +
 +
===Installation===
 +
* Download Visual SVN server for windows: http://www.visualsvn.com/server/download/
 +
* Install Visual SVN server. Choose your installation folder + repository directory
 +
 +
===Users / groups configuration===
 +
* Open the '''Visual SVN server''' application.
 +
* Open properties
 +
Action > Properties
 +
[[File:SVN server windows 1.png]]
 +
 +
*Click Repositories, adjust “Everyone” rights to Read Only
 +
[[File:SVN server windows 2.png]]
 +
 +
* Add a new user and add 'read / write' permissions to this new user
 +
[[File:SVN server windows 3.png]]
 +
[[File:SVN server windows 4.png]]
 +
[[File:SVN server windows 5.png]]
 +
 +
===Create a new repository (1) – standalone use===
 +
Right click on “repositories” -> create New Repository
 +
[[File:SVN server windows 6.png]]
 +
 +
Enter the repository name and let the server create the default structure for you:
 +
[[File:SVN server windows 7.png]]
 +
 +
→ Note the SVN URL. You’ll need it later when you’re gonna setup your project, within the maven pom.
 +
 +
 +
===Create a new repository (2) – mirror Google Code===
 +
Google provides a free subversion service through its “Google Code” service. However, there’s no quality analysis. … So, in order to provide quality checks we will mirror the google code repository.
 +
 +
Therefore, we’ll be able to perform quality scans.
 +
 +
* Create a new repository, see previous chapter
 +
* Right click on the repository -> All tasks -> Manage hooks
 +
[[File:SVN server windows 8.png]]
 +
 +
 +
You have to edit the “pre-revision property change hook” and put the following command:
 +
<syntaxhighlight lang="bash">
 +
exit 0
 +
</syntaxhighlight>
 +
 +
This will check that the execution (synchronization) was successful.
 +
[[File:SVN server windows 9.png]]
  
  

Revision as of 20:31, 26 January 2014

SVN is used to managed file revisions, branches and application releases. You have to install a SVN server, then a client on each remote computer.


SVN server

Linux (subversion)

installation

Required package

apt-get install subversion

Source folder You must indicate to subversion how it's going to work

mkdir /var/svn
mkdir /var/svn/myRepository

Set rights

chown -R www-data:www-data /var/svn/myRepository 
chmod -R 777 /var/svn/myRepository

→ Use "www-data" user:group if you want to setup web access through HTTP(S) protocol later on.


Server automatic startup

Create SVN startup script

vim /etc/init.d/svnServer

Put the following content

#!/bin/sh
### BEGIN INIT INFO
# Provides:             svn
# Required-Start:       $remote_fs
# Required-Stop:        $remote_fs
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
# Short-Description:    SVN server
### END INIT INFO

do_start () {
	svnserve -d -r /var/svn --pid-file /var/run/svnserve.pid
}
do_stop () {
	start-stop-daemon --stop --quiet --pidfile /var/run/svnserve.pid
}

case "$1" in
	start)
  		do_start
 		;;
 	stop)
 		do_stop
 		exit $?
 		;;
 	restart)
 		do_stop
		sleep 1s
 		do_start
 		;;
	*)
		echo "Usage: $0 start|stop|restart" >&2
		exit 3
		;;
esac

Set execution flags:

chmod 750 /etc/init.d/svnServer


Update boot sequence

Create symlink

ln -s /etc/init.d/svnServer /usr/bin/svnServer

Register SVN server to server startup

cd /etc/init.d
update-rc.d svnServer defaults


Start SVN server

/etc/init.d/svnServer start


How to remove SVN from boot?

Just execute the following sequence

update-rc.d -f svnserve remove


SVN repository

To do any advanced task, you've to use "svnadmin" To create repository you have to: 1. Create folder 2. Defines rights 3. Creates users


1. Create root folder

svnadmin create /var/svn/myRepo

Create repo structure

cd /var/svn/myRepo
mkdir trunk
mkdir tags
mkdir branches
chmod -R 755 */


2. Adjust rights

vim /var/svn/myRepo/conf/svnserve.conf

Adjust values:

anon-access = none		→ disable anonymous access
auth-access = write		→ allow read / write to all users
password-db = passwd		→ password required to log-in
realm = 'java'		→ Name of the current repo (without quotes!)

3. Create users

vim /var/svn/myRepo/conf/passwd

Restart your server to use the new repository.


Repository access

You can use the repository with the following SVN URL: svn://server/java


LDAP + WebSVN access

Instead of “svn://” + dedicated SVN user you can use “https://myServer/dav_svn/” + LDAP user. Please read the Apache 2 documentation to get more information.

>> TODO : add link <<


Windows

Installation

Users / groups configuration

  • Open the Visual SVN server application.
  • Open properties

Action > Properties SVN server windows 1.png

  • Click Repositories, adjust “Everyone” rights to Read Only

SVN server windows 2.png

  • Add a new user and add 'read / write' permissions to this new user

SVN server windows 3.png SVN server windows 4.png SVN server windows 5.png

Create a new repository (1) – standalone use

Right click on “repositories” -> create New Repository SVN server windows 6.png

Enter the repository name and let the server create the default structure for you: SVN server windows 7.png

→ Note the SVN URL. You’ll need it later when you’re gonna setup your project, within the maven pom.


Create a new repository (2) – mirror Google Code

Google provides a free subversion service through its “Google Code” service. However, there’s no quality analysis. … So, in order to provide quality checks we will mirror the google code repository.

Therefore, we’ll be able to perform quality scans.

  • Create a new repository, see previous chapter
  • Right click on the repository -> All tasks -> Manage hooks

SVN server windows 8.png


You have to edit the “pre-revision property change hook” and put the following command:

exit 0

This will check that the execution (synchronization) was successful. SVN server windows 9.png


SVN client

The SVN client version must match the server version for better performances and to avoid errors.


Windows

Tortoise SVN is the best one available. http://tortoisesvn.tigris.org/

!! During installation, don't forget to install the svn command line tools !!


Linux

Command line client

apt-get install subversion

Then you can use the svn command:

  • svn co --username=yourUserName --password=yourpassword http://path-to-your-svn
  • svn add file
  • svn commit -m "my revision comment"

Graphical client

RabbitVCS is a good alternative to tortoise SVN: http://rabbitvcs.org/

apt-get install rabbitvcs-cli rabbitvcs-core rabbitvcs-gedit rabbitvcs-nautilus