Skip to content

Instantly share code, notes, and snippets.

@ralph-tice
Last active September 28, 2017 19:15
Show Gist options
  • Save ralph-tice/7139341 to your computer and use it in GitHub Desktop.
Save ralph-tice/7139341 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 ci
@ralph-tice
Copy link
Author

Hmm, this is missing the git init side of the automation and setting up the git remote, in 2013 I probably did that manually since I only had a single Jenkins master. This should be illustrative enough of the concept still, but caveat emptor.

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