How to install Jenkins on CentOS 7 machine

Prerequisites:

  1. Provision machine of your choice:
    • locally
    • Virtual Machine
    • In cloud (e.g. EC2 instance in AWS with public IP address and 8080 port open)
  2. wget tool installed on CentOS machine:
    sudo yum install -y wget
    

Installation:

  1. Install required Java JDK 8 library:
    sudo yum install -y java-1.8.0-openjdk-devel
    
  2. Create and write a Jenkins repo on the machine:
    sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat/jenkins.repo
    
  3. Import the Jenkins key for the repo:
    sudo rpm --import https://pkg.jenkins.io/redhat/jenkins.io.key
    
  4. Install Jenkins:
    sudo yum install -y jenkins
    
  5. Enable autostartup of Jenkins:
    sudo systemctl enable jenkins
    
  6. Start Jenkins:
    sudo systemctl start jenkins
    

Configuration:

  1. By default you can access Jenkins server on port 8080 of the public IP address of your machine or on localhost if installed locally.
    http://[server_ip_address]:8080
    
    jenkins
  2. To unlock Jenkins you need to copy the initial Admin password in the given path on the server:
    sudo cat /var/lib/jenkins/secrets/initialAdminPassword
    
  3. After unlocking Jenkins you have two options of installing plugins. Use suggested plugins or install manually: plugin
  4. The list of suggested plugins installed on Jenkins by default: plugins2
  5. After installation of plugins is completed you need to create an admin user account: admin
  6. After creating admin user you will get an instance URL of Jenkins server: url
  7. Log-in into dashboard and start using Jenkins: dashboard

Notes:

We can install new software on Red Hat/CentOS Linux with yum install packagename command from console. Running this command first checks for existing YUM Repository configuration files in /etc/yum.repos.d/ directory. It reads each YUM Repository configuration file to get the information required to download and install new software, resolves software dependencies and installs the required RPM package files.

YUM Repository configuration files must:

  • be located in /etc/yum.repos.d/ directory
  • have .repo extension, to be recognized by YUM

If you need to get logs of Jenkins server:

sudo cat /var/log/jenkins/jenkins.log

Reference:

  1. How to download and install prebuilt OpenJDK packages
  2. YUM Repository Configuration File