An Improved Jenkins SCM Sync Configuration Plugin

One of my favorite Jenkins plugins is the SCM Sync Configuration plugin. There have been multiple occasions where I have made a change to a project configuration only to break the build. When that happened, there was no way to undo the changes and revert back to the previous configuration.

The SCM Sync Configuration plugin is a godsend, as all of your configuration settings are backed up to an SCM system (git, in my case). If you make a bad change, you can revert to an older commit or simply use the repository as a reference to manually undo your changes.

Unfortunately, if you use the mainline plugin you will find that syncing no longer works once you've deleted a job. This can be especially problematic if you are using multi-branch pipeline builds, as jobs are regularly created and deleted to correspond with active branches and pull requests.

Since the plugin seems to be currently unmaintained, I forked the repository and included fixes from elsewhere on the web. Using this new plugin version, I am happy to report that all of my SCM syncing woes have been solved.

Below I'll describe how to use my version of the SCM Sync Configuration plugin on your own Jenkins instance.

GitHub Repository

The Embedded Artistry SCM Sync Configuration plugin is hosted on GitHub. As a shortcut, here is a handy git clone reference:

git clone git@github.com:embeddedartistry/scm-sync-configuration-plugin.git

Releases

My local Jenkins instance generates plugin images. I have decided to use the GitHub releases feature to distribute binaries. If you would like to use a pre-generated plugin image, simply download the scm-sync-configuration.hpi plugin from GitHub.

Manually Building the Plugin

If you'd prefer to build locally, the process is quite simple.

First, you'll need to install Maven. Once installed, the plugin can be built by issuing the following command:

mvn install

After the build is complete, the plugin can be found at ./target/scm-sync-configuration.hpi

Installing the Plugin

If you have the existing plugin installed, uninstall it from using the Jenkins plugin manager. Then follow the instructions below to manually install scm-sync-configuration.hpi from the Jenkins web interface.

Assuming a .hpi file has been downloaded, a logged-in Jenkins administrator may upload the file from within the web UI:

  1. Navigate to the Manage Jenkins > Manage Plugins page in the web UI.
  2. Click on the Advanced tab.
  3. Choose the .hpi file under the Upload Plugin section.
  4. Upload the plugin file.

You can review the Managing Plugins documentation for further information and other approaches to installing the plugin.

References