2015/03/31

Upgrading from Subversion 1.7 to 1.8

I recently worked with an organization to upgrade their Subversion repository from 1.7 to 1.8.  The steps involved, if everything goes according to plan, are:

1. Dump the repository:

   svnadmin dump repo1_7 > repo1_7.dump

   Or you can reduce the dump size and calculate the deltas between revisions and only dump them:

   svnadmin dump --deltas repo1_7 > repo1_7.dump

2. Create the new repository, which by default uses the fsfs file system:

   svnadmin create repo1_8

3. If you need to transfer the dump file to a new host you should take care of that first but then you need load the dump:

   svnadmin load repo1_8 < repo1_7.dump


Now that would generally be it as far as the repository itself is concerned, unless you get errors.  I got errors and it is not uncommon when upgrading.  I ran into issue on step 3, loading the dump file.  It ran for about 2,000+ revisions and then stopped with these errors:

   Cannot accept non-LF line endings in 'svn:log' property

   Cannot accept non-LF line endings in 'svn:ignore' property

This occurred because the repository contained the older ^M carriage return.  This is no longer allowed after version 1.6 but the previous upgrades used the"--bypass-prop-validation" option when loading the repository which just delayed dealing with the issue.  The fix for this is to replace the ^M line endings found in the repository.  To do this you take your dump file you created in step 1 and use the following sed command to replace the ^M line endings.

   sed -e '/^svn:log$/,/^PROPS-END$/ s/^M/ /' -e '/^svn:ignore$/,/^PROPS-END$/ s/^M/\n/' repo1_7.dump > repo1_7-fix.dump

Now I want to make note that the ^M in the command above is not created with Shift+6 and Shift+M.  The ^M character is a carriage return control character that means 0D in hex.  In order to create the character you can either type CTRL+V and CTRL+M or reference it as \x0D in the sed command as shown below.

   sed -e '/^svn:log$/,/^PROPS-END$/ s/\x0D/ /' -e '/^svn:ignore$/,/^PROPS-END$/ s/\x0D/\n/' repo1_7.dump > repo1_7-fix.dump


Once that command finishes you will have repaired copy of the dump file which should load now.

2015/01/06

Configuring Jenkins to use HTTPS on CentOS 6.6

These instructions are using Jenkins 1.595 from the Jenkins Yum repository http://pkg.jenkins-ci.org/redhat/
  1. Create certificate for host with whatever tool you choose.  Personally I like XCA but I don't have a PKI system in place.

  2. Export PKCS12 certificate with chain.

  3. Convert PKCS12 certifcate to java keystore using the following command:
    keytool -importkeystore -srckeystore certificate.p12 -srcstoretype PKCS12 -destkeystore jenkinsstore

  4. Copy the keystore to a permanent location (ex. /var/lib/jenkins).

  5. Import your CA certificate into Java cacerts keystore:
    keytool -import -file CA.crt -keystore /usr/java/latest/jre/lib/security/cacerts

  6. Configure /etc/sysconfig/jenkins with the following settings:
    JENKINS_JAVA_CMD="/usr/java/latest/bin/java"
    JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Xrs -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=512m"
    JENKINS_HTTPS_PORT="8843"
    JENKINS_HTTPS_KEYSTORE="/var/lib/jenkins/jenkinsstore"
    JENKINS_HTTPS_KEYSTORE_PASSWORD="thePassword"
    JENKINS_HTTPS_LISTEN_ADDRESS="0.0.0.0"

  7. Configure iptables to redirect 443 to 8843 and to block tcp 8080 if you want to use the standard port 443:
    -A INPUT -i eth0 -p tcp -m tcp --dport 8080 -j DROP
    -A PREROUTING -i eth0 -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 8843

  8. Start Jenkins:
    service jenkins start