Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins plugins directory backup and restore

Tags:

jenkins

I'm trying to work out a way to backup and restore jenkins so we can provision a new jenkins automatically.

I cannot work out a way to backup+restore /path/to/jenkins/plugins without including the binaries. We would like the backup to be in xml file format, just as everything else in jenkins. My assumption was that we could somehow backup xml files, and jenkins could restore the plugin binaries if they are missing, since it has access to maven.

I would prefer to avoid using config management tools to install plugins, as I then I have to manage versions of plugins in a way that feels too controlled. I'm happy to just backup what ever is there, and restore it elsewhere when needed. The developers should be free to install plugins, without involving me or puppet.

Googl'ing the issue is difficult since "plugin" is used in so many other contexts.

Below link says it governs plugins as well, but I cannot see how this is - maybe I'm missing something.

http://jenkins-ci.org/content/keeping-your-configuration-and-data-subversion

I have ported the idea to use git and it generally works, except that plugins do not re-appear by magic on the new machine - only the default plugins come back.

Can anyone suggest?

like image 899
Jepper Avatar asked Oct 14 '14 18:10

Jepper


People also ask

Where are Jenkins plugins saved?

The plugins configuration is usually stored in the form of an XML file located inside the $JENKINS_HOME root, which defines the structure and settings that are mandatory for each plugin. Other times, a plugin's configuration is saved as a part of a job configuration file, such as the $JENKINS_HOME/jobs/new-job/config.

Where is Jenkins backup stored?

Configuration files are stored directly in the $JENKINS_HOME directory. ./config. xml is the main Jenkins configuration file.

Does Jenkins backup applies on home directory?

It is important to ensure that your Jenkins data is regularly backed up. This applies in particular to the Jenkins home directory, which contains your server configuration details as well as your build artifacts and build histories.


1 Answers

If you don't want to back up the plugin binary files, you can use the Jenkins REST API to get the list of current plugins:

http://jenkins:8080/pluginManager/api/json?tree=plugins[shortName,version]&pretty=true.

(You can use tree=plugins[*] to see a more complete list of fields in the API.)

Save this data as part of your configuration backup and use the Jenkins API to restore the plugins when you're re-deploying.

There's additional documentation and how to update plugins on the pluginManager API page: http://jenkins:8080/pluginManager/api

like image 131
Dave Bacher Avatar answered Oct 13 '22 02:10

Dave Bacher