替换Jenkins WAR目录后版本未更新,求保留配置的升级最优方案
Proper Jenkins Upgrade Method (Preserving Jobs & Configs)
Hey there! Let's fix that version display issue and walk through the best ways to upgrade Jenkins without losing your precious jobs and user settings.
Why swapping the WAR file alone didn't work
Most likely, Jenkins wasn't fully stopped before replacing the WAR, so the old process was still running and loading the original version. Or if you installed Jenkins via a package manager (like apt or dnf), manual WAR replacements get overridden by the package manager's managed files.
Optimal Upgrade Steps by Installation Type
1. Manual WAR Deployment (e.g., standalone or Tomcat-hosted)
Follow these steps to ensure a clean upgrade:
- Fully stop Jenkins: Don't just restart—kill all running Jenkins processes. For systemd systems:
sudo systemctl stop jenkins # Verify no processes are left ps aux | grep jenkins # Kill any remaining processes if needed sudo kill -9 <jenkins-process-id> - Backup your Jenkins home directory (critical!): This holds all your jobs, plugins, and configs. Default paths are
/var/lib/jenkins(Linux) or~/.jenkins(user-level):sudo cp -r /var/lib/jenkins /var/lib/jenkins_backup_$(date +%Y%m%d) - Replace the WAR file: Make sure you're replacing the exact WAR file Jenkins uses. For standalone Jenkins, this is the
jenkins.waryou run withjava -jar. For Tomcat, it's inTOMCAT_HOME/webapps/jenkins.war. - Start Jenkins again:
sudo systemctl start jenkins # Or for standalone: java -jar jenkins.war - Trigger post-upgrade initialization: Go to Manage Jenkins → Check for Updates to ensure Jenkins runs any necessary upgrade scripts. Then refresh the "About" dialog (clear your browser cache or use incognito mode if needed).
2. Package Manager Installation (Ubuntu/Debian/CentOS/RHEL)
If you installed Jenkins via apt, dnf, or yum, never manually replace the WAR file—use the package manager instead:
- Backup your Jenkins home directory (same as above).
- Update and upgrade Jenkins:
- For Ubuntu/Debian:
sudo apt update sudo apt install --only-upgrade jenkins - For CentOS/RHEL:
sudo dnf update jenkins sudo dnf upgrade jenkins
- For Ubuntu/Debian:
- Restart Jenkins:
sudo systemctl restart jenkins - Verify the version in the "About" dialog—it should now show the latest release.
Pro Tips to Avoid Issues
- Upgrade plugins first: Before upgrading Jenkins, go to Manage Jenkins → Plugin Manager → Installed and upgrade all outdated plugins. This prevents compatibility issues with the new Jenkins version.
- Check release notes: A quick glance at Jenkins' release notes can highlight breaking changes that might affect your specific setup.
内容的提问来源于stack exchange,提问作者Terry Bennett
相关产品推荐
相关产品推荐

