Skip to content

Instantly share code, notes, and snippets.

@dbach
Created August 25, 2010 21:44
Show Gist options
  • Save dbach/550369 to your computer and use it in GitHub Desktop.
Save dbach/550369 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Edit these values for your subversion repository
hudson_user=my_username
hudson_passwd=my_password
# Initialization -- Set up the svn repository before running this script
# cd $HUDSON_HOME
# svn mkdir --parents --username=my_username -m "Hudson configuration" REPOSITORY_URL
# svn co REPOSITORY_URL .
# Fix the svn ignore properties -- only needs to be done once
# cat > myignores <<EOF
# war
# log
# *.log
# *.tmp
# *.old
# *.bak
# *.jar
# *.json
# EOF
# svn propset svn:ignore -F myignores . && rm myignores
if [ -z "$HUDSON_HOME" ]; then
echo "error: HUDSON_HOME is not set"
exit 1
fi
cd $HUDSON_HOME
# make sure we're in a svn working directory
if [ ! -d .svn ]; then
echo "error: there is no .svn directory here. Make sure you're in the right place."
exit 1
fi
# add config that's not in the repository
svn add -q --parents *.xml jobs/*/config.xml users/*/config.xml userContent/*
# update the svn ignore property for all jobs
cat > jobsignores <<EOF
builds
last*
next*
*.csv
*.txt
*.log
workspace
cobertura
javadoc
htmlreports
ncover
doclinks
doxygen
EOF
svn propset svn:ignore -F jobsignores jobs/* && rm jobsignores
# Remove config that no longer exists
svn status | grep '^!' | awk '{print $2;}' | xargs -r svn rm
# commit the changes
svn st && svn ci --non-interactive --username $hudson_user --password $hudson_passwd -m "automated commit of Hudson configuration" && svn st
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment