Reputation: 393
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
Reputation: 655
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
.
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
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
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
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
Reputation: 2682
There is this simple solution for that.
JENKINS_HOME
folder of your exiting Jenkins instance.JENKINS_HOME
directory of your new Jenkins instance and then launch your new Jenkins.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.
And you are done :)
Upvotes: 1