How to Install Jenkins in Linux OS

How to Install Jenkins in Linux OS

Here's a simple step-by-step guide to install Jenkins on Linux (I'll explain for Ubuntu/Debian-based systems.


Step 1: Install Java (JDK)

Jenkins needs Java.

  1. Update system packages:
    sudo apt update
    
  2. Install OpenJDK (recommended version: 11 or 17):
    sudo apt install openjdk-11-jdk -y
    
  3. Verify Java installation:
    java -version
    
    You should see Java 11 (or higher).

Step 2: Add Jenkins Repository

  1. Add the GPG key:

    curl -fsSL https://pkg.jenkins.io/debian/jenkins.io-2023.key | sudo tee \
    /usr/share/keyrings/jenkins-keyring.asc > /dev/null
    
  2. Add the Jenkins repository:

    echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
    https://pkg.jenkins.io/debian binary/ | sudo tee \
    /etc/apt/sources.list.d/jenkins.list > /dev/null
    

Step 3: Install Jenkins

  1. Update packages again:

    sudo apt update
    
  2. Install Jenkins:

    sudo apt install jenkins -y
    

Step 4: Start and Enable Jenkins

  1. Start Jenkins service:

    sudo systemctl start jenkins
    
  2. Enable Jenkins to start on boot:

    sudo systemctl enable jenkins
    
  3. Check Jenkins status:

    sudo systemctl status jenkins
    

    (It should show active (running).)


Step 5: Adjust Firewall (optional)

If your system uses a firewall (like ufw):

  1. Allow port 8080:
    sudo ufw allow 8080
    sudo ufw reload
    

Step 6: Setup Jenkins via Browser

  1. Open Jenkins in browser:

    http://your_server_ip_or_hostname:8080
    

    (If you are on local machine, use http://localhost:8080.)

  2. Unlock Jenkins:

    • Find the initial admin password:
      sudo cat /var/lib/jenkins/secrets/initialAdminPassword
      
    • Copy that password.
    • Paste it into the browser to unlock Jenkins.
  3. Install Suggested Plugins.

  4. Create Admin User.


Step 7: Start Using Jenkins

  • After setup, you will reach the Jenkins Dashboard!
  • Ready to create jobs, pipelines, and automations.


Comments