Showing posts with label subversion. Show all posts
Showing posts with label subversion. Show all posts

Thursday, September 23, 2010

Subversion Edge

Subversion is an excellent version control system. It is mature enough to have all sorts of integration - with Apache and Python amongst others. This enables easy communication via the HTTP protocol and language bindings, such as python to form web interfaces for repositories.

With subversion being a server-client model the version of the server is the most important component as it determines what features you can actually use. No good having a 1.6 client if the server is 1.2 as only 1.2 features are available. Depressingly this was the situation I was in. Unsurprisingly, the good folk at CollabNet have added lots of useful new features, which I need to use.

Compiling subversion is actually dead easy (as I have discussed previously, plus lots of binaries are available). So what is Subversion Edge? Essentially a bundle of Apache, Subversion and ViewVC server in a convenient tarball. Then throw in a bonus admin web interface as well. Upgrading your server version becomes slightly more tricky when Apache and Python are tied to it. No worries with Subversion Edge as it has a built-in update mechanism. One of my pet peeves is multiple usernames/passwords. Another freebie from Subversion Edge is LDAP support so plug straight in your authentication system - nice. One less component to ensure you compile against.

I started using the beta over the summer and have had no problems. The 1.2.1 release is now happily serving many repositories for me.  If you run a very large and complicated setup you may find Subversion Edge is too restricted for you, but for a large number of users it will meet your needs.

If you maintain subversion repositories I strongly recommend you give Subversion Edge a go today. Did I mention it was free as well?

Useful links:

Tuesday, September 30, 2008

Subversion over a network

I previously talked about creating a subversion repository. But it is only of use if people can access it. 

Using svn list there are several protocols that are accepted:
  • file:///Users/svn
  • http://somedomain.com/svn
  • svn://mycomputer/Users/svn
  • svn+ssh://mycomputer/Users/svn
file is used for viewing a repository on your local machine, this approach is not recommended. http is used to view repository served via apache (Binding modules are available for this, see here). svn is the default method, simple but no data encryption. Finally there is svn+ssh, which as the name suggest uses the SSH protocol. This is my method of choice for a group that already uses SSH between workstations.

There are several changes you will need to implement first.
  1. Create an svn user and group.
  2. Change ownership of your repository to the new svn user and group (chown -R svn:svn /Users/svn)
  3. Change the file permissions to read,write, execute for user and group and nothing for other (chmod -R 770 /Users/svn)
  4. That change would of just altered an extra permission, reset it manually now: chmod g+s /Users/svn/repo/db
  5. Add users who can have SSH access to the svn group
  6. To avoid constantly entering your SSH password create a set of keys.
Now you have command-line access sorted! I'd also suggest adding a web interface to view the repository. ViewVC is excellent for this purpose. 

In terms of client applications there are plenty to choose from. Eclipse offers a cross-platform GUI for the repository using either Subclipse or Subversive plug-ins (See my previous post). There are also several other platform specific options: TortoiseSVN (Win), svnX (Mac) and KDEsvn (KDE) come to mind.

Friday, September 26, 2008

Install CruiseControl

CruiseControl (CC) is the third wheel in the pragmatic programming approach. The first two being source version control (e.g. SVN) and testing (e.g. JUnit). It is geared towards Java-based projects, but is so popular it is now available for .NET and Ruby. One of the joys of Java means that installation is a breeze as you can grab the binaries and go.

Installation on Mac OS X & Linux

A servlet server is required to run CC, thankfully one is included in the form of Jetty. You can use an existing servlet server, e.g. Tomcat. I did try to use Tomcat and while I did get the web interfaces to run I did lose some functionality, plus the dashboard isn't as mature as the JSP tool, yet.

Essentially unzip cruisecontrol-bin-2.7.3.zip into /cruisecontrol. Run cruisecontrol.sh and CC is running! Very simple, see the live webpages at http://localhost:8080 and http://localhost:8080/dashboard. Make sure ports 8080 and 8000 are allowed on your firewall. (8000 for JMX, see later). If you don't get anything look in the log file, cruisecontrol.log. You can alter the ports in cruisecontrol.sh.

Now CC is up and running lets go through the components. 
  1. The build loop, this is the java process which monitors your selected CVS/SVN repositories, if it detects a change (e.g. you commit something) it will checkout the project to a local directory and attempt to compile/test/package it as per your instructions in your build.xml. If you don't have ant scripts for your projects now is the time to write them. The build loop will then report the results, either a pass or fail with details for failed unit tests/compilation errors.
  2. The reporting loop, originally this just consisted of JSP pages, now dashboard has come along in web 2.0 glory. Dashboard does everything the JSP pages do and more, plus is far easier on the eye. With both tools you can force a build of your project (this uses JMX and this requires an open port, 8000, to communicate on), if you don't want to wait for the next scheduled build. All the XML reports from the build loop are displayed in the two interfaces.
To configure your CC instance edit config.xml, it comes with a sample project in. Use it to construct your project settings and read this to see what else is available (e.g. email users upon a failed build, attach artifacts to successful build, e.g. a jar).

Finally you will want to add Subversion functionality to CC by seeing my previous post. The built-in support doesn't seem to actually work.

Monday, September 22, 2008

Install and setup subversion

We use the popular successor of CVS for our version control, subversion. It is ideal to hold our various projects. In addition to excellent command-line tools it has integration with Eclipse through Subclipse or Subversive and web-based repository viewers, like ViewVC.

Mac OS X
Binary installs are now available from here. Alternatively download from MacPorts or Fink.

openSUSE

You can grab subversion from YaST, but you may not be able to get 1.5 (only 1.4 if using 10.x), thankfully installing the source is very straight forward. Get both the subversion source and dependencies (subversion-deps). Decompress both and run ./configure;make;make install as root. An additional quirk we found on 64-bit openSUSE was that neon must be compiled first:
cd neon
./configure --enable-shared
make
make install
Then run ./configure;make;make install in the folder above.

Create a repository
Use the included admin tool:
svnadmin create /srv/svn
Access this repository as file:///srv/svn, e.g. to see contents issue:
svn list file:///srv/svn
Use svn import, svn ci & svn co to import your initial project, check-in changes and checkout a project. Run svn help to get full details on these and other commands. I'd also recommend checking out the svn book.

To access this repository over a network some additional steps are required so I'll address that in another post.

Tuesday, July 8, 2008

Subversion with CruiseControl

As we use subversion for our version control we need to do an extra step as CruiseControl only has limited subversion support (e.g. it can't checkout a project, I'm sure it should but has never worked for me).

To give it the power to do so you need to download SvnAnt. Copy the three jar's from the lib folder into the the lib folder in your installation: /cruisecontrol/apache-ant-1.7.0/lib. This way everything that keeps CruiseControl happy is in one place.Now you need to define a property file defining the location of SvnAnt, something like the file svn-build.props:
svnant.version=1.0.0

lib.dir=../apache-ant-1.7.0/lib

svnant.jar=${lib.dir}/svnant.jar
svnClientAdapter.jar=${lib.dir}/svnClientAdapter.jar
svnjavahl.jar=${lib.dir}/svnjavahl.jar
You need to ensure the lib.dir value is valid, depending where you call this file from (in this example /cruisecontrol/project). As you will see we make a wrapper script to grab the code from the repo, before launching the project ant script. The wrapper script may be in /cruisecontrol/project, but defines it basedir as /cruisecontrol/checkout.

A sample script can be found here (Blogger doesn't want to display it). To use it save to /cruisecontrol/project and edit the sample_project and subversion path. Your project will be checked out to /cruisecontrol/checkout, where it is built, tested, compiled etc. For the first time I had to checkout manually otherwise CruiseControl would kick a fuss up.

In your main config.xml call the new wrapper script (/cruisecontrol/project/sample_project.xml) in the schedule section. This way a fresh copy of the code is checked out before the CruiseControl commences the build.

Thursday, June 26, 2008

Subversion integration with Eclipse

The latest version of Eclipse, Ganymede, has just been released. I'm a keen Eclipse user, I like having all my programming needs met by one application (mainly thanks to many language plugins available; Perl, Shell, LaTeX etc.).

I'm not going to detail why you might want to upgrade to ganymede as there is plenty on that already. All I will say is that, as with previously releases, only some (in this case 23) of the ~90 projects that make up eclipse are actually releasing new milestones in this release, so your favourite subproject may not be updated at the current time.

For me the most important plugin is subversion (although, personally I feel this should be built in like CVS support). Previously I have used Subclipse, but I thought I'd try Subversive this time around.

Installation is fairly straightforward:
  1. Open Software update
  2. Select the Ganymede update site
  3. From Collaborative Tools pick SVN Team Provider

This doesn't include an SVN connector, which is a show stopper!
  1. Add http://www.polarion.org/projects/subversive/download/eclipse/2.0/update-site/ as a new remote site in software update
  2. For future reference get the latest update site from http://www.eclipse.org/subversive/downloads.php
  3. Install SVNKit 1.x Implementation, or 2.x if you want to try the beta.
Now you should be good to go. Select SVN from the New Project Wizard, and explore repositories from the SVN Repository Exploring perspective (Window > Open Perspective > Other...)

Subversion users should also note that version 1.5 has also recently been released, and accordingly you will want your clients to run this version.

If Subversive isn't for you Subclipse works fine in Ganymede too.