More often than not, you’ll find yourself (or your fellow colleagues) making a lot of changes to the various jobs that you have on Jenkins.
Sometimes you may want to revert a change or more, other times you may encounter a problem with a job and you want to trace the changes that were made to that job.
For those scenarios and others that require you to keep track of your job’s configuration, you can utilize the jobConfigHistory plugin.
This plugin enables you to view all the changes that have happened to the job’s config.xml file and also revert to a previous version of that file.
To install the plugin, follow these steps:
- Navigate to the plugin manager page.
- Search for jobConfigHistory in the Available tab.
- Check the plugin name.
- Click install without restart.
Once the plugin is installed, you can configure it as follows:
- Go to Configure System (from Manage Jenkins).
- Scroll down to the Job Config History section.
You have several options to configure, the most important of which are:
- Use different history directory than default: You can specify a custom directory for storing your history. Ensure that Jenkins has permissions to access and write to that path.
- Max number of history entries to keep: This determines the highest number of changes that the system will keep for you. Leaving it blank will save all changes.
- Max number of days to keep history entries: This specifies the length of time (in days) that the system should keep the job history. Leaving it blank will keep the changes indefinitely.
Now let’s test the plugin:
- Go to the hello-world-integration job and add a description. Save the job.
- Navigate to Job Config History by clicking on the navigational link in the left column.
- Click “Show job configs only” to filter the output. You’ll see a record reporting a change for this job.
- Go to the same job again and delete the description. Save the configuration.
- Return to Job Config History. You’ll notice that we have two entries, and the first entry has a “Fast backward” button. Clicking this button will restore the job to the state it was in when the snapshot was taken.
- Click the restore button and ensure that the job has the description back.