Jenkins – Server Maintenance
The following are the basic activities that you will carry out, some of which are best practices for Jenkins server maintenance.
URL Options
Append the following commands to the Jenkins URL to perform the following operations:
- http://localhost:8080/jenkins/exit – shutdown jenkins
- http://localhost:8080/jenkins/restart – restart jenkins
- http://localhost:8080/jenkins/reload – to reload the configuration
Backup Jenkins Home
There is one location on your drive where Jenkins stores all the information for the jobs, builds, etc., is called Jenkins Home Directory.
You can see the location of the home directory by clicking on Manage Jenkins -> Configure System.
Set up Jenkins on the system’s partition that has the most disk-space free. Since Jenkins would be taking source code for the different jobs defined and doing continuous builds, always make sure that Jenkins is set up on a drive that has enough hard disk space. If your hard disk has no space or your hard disk runs out of space, then all builds on the Jenkins instance will start failing.
Another thing is to write cron jobs or maintenance tasks that can carry out cleanup operations to avoid the disk where Jenkins is set up from becoming full.
Configuration
- Always configure your build or job to generate trend reports and automated testing when running a Testing job.
- Use of public key authentication: – by setting up the public key mechanism, anyone can log in from one system to another system without ever entering a password. This is a very useful timesaver option for Jenkins.
- Use of Labels: Sometimes, it is good to keep more range in a build cluster. One way to manage diversity is with labels to a particular node. The right usage of labels helps teams to identify the uniqueness of each node and use it for the right purpose.
- Parallel execution is a better way to see the results and feedback quickly. Every pipeline should recognize the list of jobs which can be executed in parallel.
Maintenance
- Every job should contain relevant script to clean up the operation after completion to maintain cleanliness.
- Jenkins should also contain maintenance jobs such as cleanup operations to avoid full disk problems.
- Always say no to Build Record Sprawl. You should remove old builds with the configuration option.
- Once in a while, your team should archive unused jobs before eventually removing them.
- Almost every pipeline job ultimately outgrows the ability to run builds on just one machine. Get advantage of Distributed Builds. In larger systems, ensure all jobs run on slaves.