Tracking configuration changes in Jenkins

From my experience you want to put mostly everything in software projects under versioning. Not only your production code, but also build and deployment scripts. This doesn't always prove to be straightforward. With the SCM Sync configuration plugin there is a beautiful plugin for versioning all Jenkins configuration under Git (or SVN). Here are my quick notes on how I got it running on my newest project.

  1. Install the plugin through the normal Jenkins process
  2. As described here create a SSH key for the Jenkins box and register it as a "deploy key" with Github:
    $ sudo -u jenkins bash
    $ ssh-keygen
    Follow the steps and create a key without a passphrase. Now copy the contents from ~/.ssh/id_rsa.pub to https://github.com/YOUR_USER/YOUR_REPO/settings/keys
  3. Set-up Git globally on the machine:
    $ sudo -u jenkins bash
    $ HOME=/Users/Shared/Jenkins/ git config –global user.email YOUR_EMAIL
    $ HOME=/Users/Shared/Jenkins/ git config –global user.name Jenkins
  4. Add git@github.com:YOUR_USER/YOUR_REPO.git as SCM root to "SCM Sync configuration" under http://YOUR_JENKINS/configure
The path under 3. should point to your Jenkins home folder. If your setup is similar to mine, you might not have a regular Jenkins user that you can log in with. Faking the HOME directory was the quickest way to get Git to accept the parameters.

This should be enough to have the given user now push to Github whenever somebody changes something in the configuration.

Leave a comment