Guardian
Guardian

Reputation: 393

How to transfer Jenkins plugins and settings

I got a task in which i have to setup new jenkins server and copy jobs,plugins,settings etc from existing server. So far I copied all the jobs but how to import all the plugins and settings we have on jenkins didn't find the answer.

If there is any plugin that will do the work will be helpful

Upvotes: 1

Views: 4574

Answers (3)

Assuming you have already created a new Jenkins service, and you want to copy all plugins from a path/to/old/JENKINS_HOME to your newly path/to/new/JENKINS_HOME.

Download Jenkins plugin installation manager tool

Export The Plugins To A File

to export a yaml file (for example plugins.yaml), run:

WARNING: in this implementation we removed the version for each plugin, so jenkins will install the latest versions of the plugins.

java -jar jenkins-plugin-manager-*.jar --war /path/to/jenkins.war --plugin-download-directory "path/to/new/JENKINS_HOME/plugins" -l --output yaml | sed '/source:/d' | sed '/version:/d' | tee path/to/new/JENKINS_HOME/plugins-from-old-installation.yaml

Import The Plugins From A File

then to install the list of plugins from the exported file (for example plugins.yaml):

WARNING: in this implementation we allow the security rules that were allowed in the old installation, with the --hide-security-warnings option.

java -jar jenkins-plugin-manager-*.jar --war /usr/share/java/jenkins.war --plugin-download-directory "path/to/old/JENKINS_HOME/plugins" --plugin-file path/to/new/JENKINS_HOME/plugins-from-old-installation.yaml --hide-security-warnings

Copy All The Plugins' Configurations

WARNING: in this implementation we copy all the plugins' configurations, as well as all the configurations of the entire system that may not be relevant to these plugins (such as credentials... etc...)!

Copy all the .xml files that are in the root directory of the old JENKINS_HOME to the new JENKINS_HOME. Like so:

ls 'path/to/old/JENKINS_HOME' | grep '.*.\xml$' | xargs -I{} cp {} 'path/to/new/JENKINS_HOME'

After you installed the plugins, you need to restart the jenkins service for them to take an effect:

sudo systemctl restart jenkins

Upvotes: 0

psalvi21
psalvi21

Reputation: 143

For similar kind of task I wrote python script to migrate plugins & jobs from one Jenkins instance to another using Jenkins Rest API. You can find the detailed steps in this post How to move Jenkins from one PC to another?

Upvotes: 1

ANIL
ANIL

Reputation: 2682

There is this simple solution for that.

  1. Stop your existing Jenkins server and also the new Jenkins server that you have installed.
  2. Create a archive file of all the contents in the JENKINS_HOME folder of your exiting Jenkins instance.
  3. Now, extract that archive file to the JENKINS_HOME directory of your new Jenkins instance and then launch your new Jenkins.
  4. Now in your new Jenkins instance go to Manage Jenkins -> Configure System and find Jenkins Location section and then under theJenkins URL field change the URL that points to the new Jenkins instance. enter image description here

And you are done :)

Upvotes: 1

Related Questions