You started the uninstallation of a plugin in Jenkins via the web UI. The plugin now says "Uninstallation pending" in the web UI. You changed your mind (or you accidentally initiated the process to remove the plugin by clicking the "Uninstall" button) about removing the plugin. What do you do to keep the plugin continuously installed in Jenkins?
When you initiate the uninstallation of a plugin, behind-the-scenes you delete a .hpi or .jpi file from the plugins directory of Jenkins. The directory of other files associated with that plugin, which reside in the plugins directory on the server, will be deleted upon next restart of the Jenkins service. Those files still exist, but the .hpi or .jpi file gets deleted immediately.
This solution requires access to the back-end of the Jenkins server and a copy of .jpi (or .hpi) file for the plugin. You could download one from here (and rename the .hpi file to .jpi, but we expect the files to start being called .jpi soon). If you are not sure if you had an .hpi or .jpi file, look at what is in the .../jenkins/plugins/ directory. If you have mostly other .jpi files, we recommend assuming you need a .jpi file. In our experience a .hpi file can be renamed to be a .jpi file and work fine.
1. This step involves getting the .jpi (or .hpi) file of the plugin you want to keep installed. Here are two commands to get a gradle.jpi file from a different source.
curl -L https://updates.jenkins.io/download/plugins/gradle/1.28/gradle.hpi > /tmp/gradle.jpi
sudo mv /tmp/gradle.jpi /var/lib/jenkins/plugins/gradle.jpi
Ideally the .jpi will be the same version as the old version. If it is the exact same version, the uninstallation will not happen (in accord with your intentions).
Restore from backups or copy a .jpi file to /var/lib/jenkins/plugins/ (or whatever directory is your .../jenkins/plugins/ directory) from a back up or a different machine with the same archiecture and version of Jenkins.
2. Move the respective plugin subdirectory to be assume a new name. For example, if you are uninstalling the Gradle plugin, do something like this:
sudo mv gradle gradlenew
3. Now move the directory back to its original name. If you were doing this for Gradle, do something like this:
sudo mv gradlenew gradle
Next time Jenkins is restarted, the plugin will not be uninstalled. The plugin will remain installed on Jenkins, and the removal process will be cancelled. Until Jenkins is restarted remember that you must ignore the "Uninstallation pending" comment in the "Installed" plugins section of the Jenkins web UI.