Thursday 16 December 2010

Hudson Jobs in the subversion repository

Everyday morning the first thing i look after entering the office is Hudson. It doesn't mean i am an expert in hudson, i am still in the learning phase .We decided to bring all the Hudson contents to subversion ,that's the version control tool we use to maintain our source code. Once we move everything in to subversion we no need to worry about losing the data and its easy for maintenace. As our company follow the Agile methodology the continuous integration plays an important role that's where Hudson comes in to picture. So as the first step towards this, we moved the Jobs directory in to the subversion. This task was given to me ,already there was a repository created for committing the Hudson content's .So i decided to use `svn import` as this doesn't need a working copy to be checked out and it also creates the intermediate directory if it doesn't exist in the repository but import don't accept multiple arguments so can't pass all the jobs in a single command and also can't import the whole jobs directory in a single shot as the jobs directory size was more than 20GB and we weren't sure whether subversion can handle such large data ,so decided to write a shell script which will do the import one by one by going through the loop. Below is the shell script which does this work.

cat svn-import.sh

./svn-import.sh password

#! /bin/bash
import_dir=(5.4 5.4.1 6.1 6.0.2)
for i in ${import_dir[@]}
do
echo "processing $i"
for f in $i\*
do
:
for a in $f
do
b=`echo $a| cut -d '/' -f4`
echo `svn import $a/* https://forge.collab.net/svn/repos/hudson/relenghub/jobs/$a/* -m "[artf78984] Adding the $b hudson jobs to subversion for easy maintenance and recovery" --username=madhu --password=$1 --no-auth-cache` &> "/tmp/import.log"
done                                                  done

done

And used the same script to copy the files from one directory to another,

cat copy.sh

./copy.sh


#!/bin/bash
import_dir=(5.4.1 6.1 6.0.2)
for i in ${import_dir[@]}
do
echo "processing $i"
for f in $i\*
do
echo $f
for a in $f
do
/bin/cp -v -r $a/2010-12-1[1,2,3]*   /tmp/jobs/$a/
/bin/cp -v -r $a/builds/2010-12-1[1,2,3]*   /tmp/jobs/$a/builds/
/bin/cp -v -r $a/config.xml   /tmp/jobs/$a/config.xml
done                                                                                                                                                                                                                                               done
done

No comments:

Post a Comment