jenkins upgrade
Install
Update system
sudo apt update && sudo apt upgrade -y
Install Java (Java 17 or 21)
sudo apt install openjdk-21-jre -y
java -version
Add repository
sudo wget -O /etc/apt/keyrings/jenkins-keyring.asc https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
echo "deb [signed-by=/etc/apt/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian-stable binary/" | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null
Check available versions
sudo apt-cache madison jenkins
Install specific (e.g., 2.504.3)
sudo apt-get install -y jenkins=2.504.3
sudo systemctl enable jenkins
Backup Jenkins
Locate the Jenkins home directory
- Check
JENKINS_HOME
variable
Key directories
config.xml
: The main configuration file (global settings, security, etc.)jobs/
: Contains subdirectories for each job, including their config.xml (job settings) and builds/ (build history)plugins/
: Contains installed plugins, though you can reinstall these latersecrets/
: Stores encryption keys and credentials (e.g., master.key, hudson.util.Secret)
Stop Jenkins
sudo systemctl stop jenkins
Backup
sudo cp -r /var/lib/jenkins /backup/path/
Upgrade
Update packages
sudo apt-get update
sudo apt-get upgrade jenkins -y
Or specific version
sudo apt-get install jenkins=NEW.VERSION
Restart
sudo systemctl restart jenkins
Rollback
Stop service
sudo systemctl stop jenkins
Restore backup
sudo cp -r /backup/path/jenkins /var/lib/
Reinstall previous version
sudo apt-get install jenkins=OLD.VERSION
Restart
sudo systemctl restart jenkins