Skip to content

Instantly share code, notes, and snippets.

@ralph-tice
Last active December 25, 2015 05:39
Show Gist options
  • Save ralph-tice/9842bbddd68b1797b63f to your computer and use it in GitHub Desktop.
Save ralph-tice/9842bbddd68b1797b63f to your computer and use it in GitHub Desktop.
version control jenkins and jobs this shell snippet itself can be used as a jenkins job and it will add itself.
cd /var/lib/jenkins
git add userContent/* -f
git add jobs/*/*.xml -f
git add users/*/config.xml -f
git add *.xml
COUNT=`git ls-files --deleted | wc -l`
if [ $COUNT -ne 0 ]
then git ls-files --deleted | xargs -d '\n' git rm
fi
git commit -m "autocommit by jenkins job because $BUILD_CAUSE"
# Push the commit up to the remote repository.
git push origin jenkins
@ralph-tice
Copy link
Author

Updated with a bug fix -- previous version didn't delete correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment