Skip to content

Instantly share code, notes, and snippets.

@MichaelBitard
Last active August 24, 2018 07:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MichaelBitard/4203724 to your computer and use it in GitHub Desktop.
Save MichaelBitard/4203724 to your computer and use it in GitHub Desktop.
Jenkins configuration under subversion
#!/bin/sh
# Edit these values for your subversion repository
jenkins_user=user
jenkins_passwd=password
repository_url="http://your_svn_dir/"
cd /your/jenkins/path
# make sure we're in a svn working directory
if [ ! -d .svn ]; then
echo "error: there is no .svn directory here. We checkout"
svn co --username=$jenkins_user --password=$jenkins_passwd $repository_url .
exit 1
fi
# Fix the svn ignore properties -- only needs to be done once
cat > myignores <<EOF
war
log
tools
*.log
*.tmp
*.old
*.bak
*.jar
*.json
*.war
.*
*.key
fingerprints
plugins
updates
contributed-localizations
svn-prop.tmp.save
EOF
svn propset svn:ignore -F myignores . && rm myignores
svn up
# Remove config that no longer exists
svn status | grep '^!' | awk '{print $2;}' | xargs -r svn rm
# 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
*.tmp
workspace
cobertura
javadoc
htmlreports
ncover
doclinks
doxygen
modules
config-history
subversion.credentials
EOF
svn propset svn:ignore -F jobsignores jobs/* && rm jobsignores
# commit the changes
svn st && svn ci --non-interactive --username $jenkins_user --password $jenkins_passwd -m "automated commit of Jenkins configuration" && svn st
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment