Last active
September 28, 2017 19:15
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Now that AWS has Code Commit, this is a pretty compelling way (IMO) to persist Jenkins config for legacy deployments.
One step better is to use https://docs.openstack.org/infra/jenkins-job-builder/
An order of magnitude better is to use Jenkins Pipelines, https://jenkins.io/doc/book/pipeline/ -- a decent bullet point overview of a comprehensive implementation is here: http://slides.com/rocktavious/uacf-ci#/
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
this is a dupe of https://gist.github.com/ralph-tice/9842bbddd68b1797b63f
not sure why i made it again, but i added the bug fix to the original