All Jenkins plugins are lost when migrating to new Jenkins Server - jenkins

I have a jenkins server version 1.584 which has at least 50 plugins.
I wanted to check whether i can do an update for the jenkins core, and I didn't want to do it on the original server. Therefore I copied all the folders (expect the builds and modules folders that were under jobs folder) and then started jenkins.
Now it looks like i have no plugin installed at all.
Hope to hear about some way to handle it...
Thanks.

Did you copy the plugins folder to the new Jenkins home ?
It should work.

Did you also copy those *.xml configuration files from your_old_server_jenkins_home/* into your_new_server_jenkins_home/* ?

Related

Jenkins install plugins offline

Installed Jenkins on a Linux server and want to install some plugins manually.
I want to install Blue Ocean and Artifactory.
For both plugins I downloaded the hpi file and tried to install it, but I get a lot of dependency errors.
Do I now have to install those dependencies manually as well? or is there a better way to do this?
I tried to install one of those dependency and that one also had some dependency errors as well :-(
The Linux server is not able to access the internet.
Thanks!
Robert
You are correct that BlueOcean has a lot of dependencies.
Given you are not able to connect to the internet you will need to download all 21 BlueOcean related hpi files and upload them from the Manage Jenkins > Manage Plugins > Advanced tab.
Alternatively, if you have access to the server that your Jenkins instance is running on you can copy the hpi files into the %JENKINS_HOME%/plugins folder. The corresponding directories (exploded from the hpi, which is just a zip file) will be created on Jenkins restart.
The easiest way to acquire all 21 plugin files is to open The Jenkins plugin page and search for blueocean. Download the same numbered version of all 21 and upload them one by one. Order shouldn't be an issue. As long as they are all present on restart the dependencies will resolve.
Same process goes for any other plugin. If you're able to get the machine connected to the internet it will make the process a lot simpler as you will be able to use the update center, which manages dependencies and update notifications.
Same case here. Our Jenkins is setup in OpenShift which is not allowed to connect to the Internet. Downloading a plugin 1-by-1 is tiresome. Not to mention that each plugins have its own dependencies that needs to be downloaded as well.
Here's what you would do...
Run a Jenkins locally in a machine that can download plugins.
Download and update all the plugins you want using the Update Center.
Go %JENKINS_HOME%/plugins directory. Inside this folder you would see *.jpi. These are your plugins. Its dependencies will be downloaded as well.
Rename it to *.hpi then keep it in some directory.
To test...
In your local Jenkins delete everything in %JENKINS_HOME%/plugins directory then put all *.hpi in this directory.
Restart your local Jenkins.
Verify if the plugins you require are installed and updated.

Upgrade Jenkins CI withourt losing User/Job Config

I would like to upgrade Jenkins to the latest version without losing job/user configuration.
From looking through various posts the answer seems to be to replace the jenkins war directory.
I did this and although the new version seems to be in place the about dialogue still has the original version,
I think this is because the versionnumber is held in a config file outside of the war folder.
Is there a better method to upgrade.
I have the best practice with replacing jenkins.war file, content of the folder should got extracted from war file during server startup (automatically).
All configuration is stored as files in jenkins home directory.
jobs in subfolder jobs, users in users etc.
So if you will replace war file, you will dont loose the configuration or content.
You can check this for better info, looks for "Install the New Jenkins War File
"
I am sharing my experience here, as this would definitely help someone. We were on jenkins 2.138.3 and wanted to upgrade to 2.235.5 version. Now the issue we were facing is our users were getting deleted when we tried to restore the users folder from the backup of old jenkins.
Root Cause: In the jenkins upgrade the mechanism to store the users on the disk is changed. This is verified by seeing the users//config.xml of both old and new jenkins.
The first problem we faced starting the jenkins is below error
java.nio.file.DirectoryNotEmptyException: /Users/jenkins/<username>
The reason being, in the upgraded jenkins the username folder is changed. for e.g. if your username is admin then in new jenkins the folder would be something like $JENKINS_HOME/users/admin_6635238516816951048/ instead of $JENKINS_HOME/users/admin/ and this mapping is captured separately in a file
$JENKINS_HOME/users/users.xml where a sample entry would look like
<entry>
<string>admin_6635238516816951048</string>
<string>admin_6635238516816951048</string>
</entry>
Here the first String is your username and second is the folder where config.xml for your user should exists.
In our old jenkins this folder structure is not available and hence we see the error
java.nio.file.DirectoryNotEmptyException: /Users/jenkins/<username>
So, what are the steps to migrate users properly so existing credentials can be used.
Once the new jenkins war is deployed on the new jenkins, stop the jenkins.
If there exists a users.xml file in $JENKINS_HOME/users/users.xml, delete it or rename it so jenkins wont look for the new folder structure
Restore your users folder from old jenkins to new jenkins at $JENKINS_HOME location. So all your users should appear in new jenkins # $JENKINS_HOME/users folder
Start the jenkins service.
And you should be able to login with your old jenkins user's credentials.
The detailed explanation can be found at
https://www.jenkins.io/doc/upgrade-guide/2.138/#SECURITY-1072

Migrate from jenkins 1 to jenkins 2

How can we migrate our jenkins 1 instance to jenkins 2.
We know the job export plugin which can be useful for all our the jobs but is there also a way to export your general settings / security settings?
Jenkins 2 is a drop-in replacement. You can just upgrade from version 1 to 2, either by updating the server running Jenkins, or by copying the Jenkins directory.
Don't export anything. Jenkins stores EVERYTHING in 1 directory (unless you have told it not to). Copy that entire directory to a new machine. Copy the existing jar. Start up Jenkins. If it works, replace the jar with the new version. Start it up. Chances are, it will just work.

Does uninstall a plugin causes in Jenkins/Hudson job config file to lose its plugin changes?

We are trying to troubleshoot why our job config page is not loading.
If we uninstall each plugin as we troubleshoot, would Hudson or Jenkins modify the job config files that had previously used those installed plugins
and remove those plugins tags just because we uninstalled them temporarily ?
We ask because we like to know if we need to make job config backups as we do not want to lose the old installed plugin tags used in our jobs.
Thank you
Sincerely
Yes, you should be doing job config backups! Yes, you probably should rsync your job config data and jenkins directories sans workspaces to a different system for debugging.
No, when you uninstall a plugin, the data that is associated with that plugin is generally left behind, unless you modify a job afterwards.

jenkins missing jobs after removal of plugins

I have a Jenkins Server (1.510) on Win 2008 with ~100 jobs.
After installing and then uninstalling the CloudBees (Plugin_1, Plugin_2) set of plugins + restart I have the following issues:
half of the Jobs are now missing.
many plugins are not functioning well, for example the green-balls plugin is not working and also the entry to launch the backup plugin is missing
many built in Jenkins buttons such the new "Credentials" is missing from the "Jenkins Configure" Menu.
Looking at the FS, i still see all the jobs.
I already tried :
Using the reload configuration
Reinstalling the plugins
Reinstalling Jenkins with the same version once again
Still the jobs are missing
Any idea how to solve it?
Thanks,
Doron
When job is loaded, many of the related Java classes get instantiated. If instantiation fails, usually because some plugin has been removed and that class is no longer available at all, then the job is hidden.
I suspect you have accidentally removed some other plugin too.
Note: Before actually doing anything, take full backup! Easiest is to backup entire Jenkins folder, where the jobs, configuration etc reside.
Easiest solution might be to just install Jenkins from scratch, install the plugins you do need (see below for troubleshooting if you're missing some), then copy the jobs subfolder to the new Jenkins. It might be best to do any configuration under Manage Jenkins by hand, but you can also just try copying the related XML config files.
If you are missing a plugin and can't figure out which one, you should look at jenkins.out.log and jenkins.err.log log files and search for exceptions happening after Jenkins is started. That may give you a clue on what plugin you are missing.
You can also try editing the job XML files to remove build steps you identified from the exceptions (remember to take backups first!), then restart Jenkins or select Reload configuration from disk from Manage Jenkins page.
If not solved, but you find relevant-looking exceptions or something else interesting, please update the question with details.
After I upgraded Jenkins, one of my jobs disappeared. I found out that although my job directory still existed, the config.xml file inside had somehow gone missing.
I restored this file from a backup, after updating all the plugins that needed updating, and reloaded the configuration, and the job reappeared in Jenkins.

Resources