Install Jenkins on Ubuntu and CentOS

Install Jenkins on Ubuntu and CentOS

Install Java

To run Jenkins your system need to have Java. So first we will install Java and then Jenkins.

  1. Ubuntu:

    1. Update the packages: sudo apt update

    2. Install Java: sudo apt install openjdk-11-jre -y

    3. Check installation: java -version

  2. CentOS/Fedora:

    1. Install Java: sudo dnf install java-11-openjdk

Install Jenkins

  1. Ubuntu:

    1. Install keys and setup (run commands one by one):

      You can also refer to this official website for updated packages:https://www.jenkins.io/doc/book/installing/linux/

      1.   curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \
            /usr/share/keyrings/jenkins-keyring.asc > /dev/null
        
      2.   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/null
        
    2. update packages: sudo apt-get update

    3. Install Jenkins: sudo apt-get install jenkins -y

  2. CentOS/Fedora:

    1. Install keys and setup (run commands one by one):

      You can also refer to this official website for updated packages:https://www.jenkins.io/doc/book/installing/linux/

      1.   sudo wget -O /etc/yum.repos.d/jenkins.repo \
              https://pkg.jenkins.io/redhat-stable/jenkins.repo
        
      2.   sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
        
    2. Packages Update: sudo dnf upgrade

    3. Install Jenkins: sudo dnf install jenkins

    4. Reload daemon: sudo systemctl daemon-reload

Done. You have successfully installed Jenkins in your system.

Jenkins Status

  1. Check the status of Jenkins with systemctl :

Stop Jenkins

  1. Use systemctl stop to stop the Jenkins

Uninstall Jenkins

  1. Stop Jenkins with sudo systemctl stop jenkins

  2. Remove the Jenkins packages

    1. CentOS/Fedora machine: sudo yum -y remove jenkins

    2. Ubuntu: sudo apt-get remove --purge jenkins

  3. Remove the Jenkins Working Directory: rm -rf /var/lib/jenkins

  4. Remove User and Group: sudo userdel jenkins

  5. Reboot the system sudo reboot now

  6. Auto Remove Unwanted Packages(optional. Ubuntu): sudo apt-get autoremove

Done. You have successfully removed Jenkins from your system.

To activate Jenkins and use it for automation, we will see it in another blog.

For further query do comment on this post.