How to install Jenkins on linux

How to install Jenkins on linux

Jenkins is an open-source automation server widely used for continuous integration (CI) and continuous delivery (CD) processes in software development. It helps developers automate the building, testing, and deployment of applications, making it easier to deliver high-quality software quickly and efficiently.

Prerequisites for installing jenkins on Linux :

  1. Linux Machine: You'll need a Linux-based operating system installed, such as Ubuntu, CentOS, or Debian.

  2. Java: Jenkins requires Java to run. Ensure that you have Java Development Kit (JDK) or OpenJDK installed on your Linux machine.

  3. Internet Access: Ensure that your Linux machine has internet connectivity to download packages and dependencies during the installation process.

  4. System Requirements: Check the system requirements for the Linux distribution you are using to ensure it meets the minimum specifications for Jenkins.

  5. Firewall Configuration: If you have a firewall enabled on your Linux machine, make sure to configure it to allow incoming connections to the Jenkins port (default is 8080) or disable the firewall temporarily during the installation process.

  6. User Access: Ensure that you have administrative or root access to the Linux machine to install software packages and make necessary configurations.

Choose the Linux Distribution

  • Provide an overview of different Linux distributions and guide readers on selecting the one that suits their needs. Mention popular distributions like Ubuntu, CentOS, and Debian.
  1. Update System Packages: Open a terminal and run the following commands to update your system's package lists:
sudo apt update
  1. Install Java: Jenkins requires Java to run. Install OpenJDK, which is a free and open-source implementation of Java:
sudo apt install openjdk-11-jre
  1. Add Jenkins Repository Key: Add the Jenkins repository key to ensure package authenticity:
curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \
/usr/share/keyrings/jenkins-keyring.asc > /dev/null
  1. Add Jenkins Repository: Add the Jenkins repository to the package sources list:
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
/etc/apt/sources.list.d/jenkins.list > /dev/nul
  1. Update System Packages Again: Run the following command to update your system's package lists with the new Jenkins repository:
sudo apt-get update
  1. Install Jenkins: Install Jenkins with the following command:
sudo apt-get install jenkins
  1. Start Jenkins: Start the Jenkins service:
sudo systemctl start jenkins
  1. Enable Jenkins on System Startup: To ensure Jenkins starts automatically on system startup, run the following command:
sudo systemctl enable jenkins
  1. Check Jenkins Status: Verify the status of the Jenkins service to ensure it is running:
sudo systemctl status jenkins
  1. Access Jenkins Web Interface: Open a web browser and enter http://localhost:8080 or http://<your-server-IP>:8080 to access the Jenkins web interface.

  2. Unlock Jenkins: During the first access, Jenkins will ask you to unlock it by retrieving the initial administrator password. Run the following command to get the password:

sudo cat /var/lib/jenkins/secrets/initialAdminPassword

Copy the password and paste it into the Jenkins web interface.

  1. Customize Jenkins: Follow the on-screen instructions to customize Jenkins according to your preferences.

That's it! You have successfully installed Jenkins on Linux. You can now create your Jenkins jobs and configure your CI/CD pipelines. Enjoy exploring the power of Jenkins for automation and continuous integration!

Thank you