1. First do sudo yum install wget
Wget command is a Linux command line utility that helps us to download the files from the web. We can download the files from web servers using HTTP, HTTPS and FTP protocols. We can use wget in scripts and cronjobs. Wget is a non-interactive program so that it will run in the background.
2. Get the latest Jenkins repo in local server by using the following command
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
(it is -O is alphat capital O)
You should see the following on your linux terminal.
3. Now import the Jenkins repo associated key with that repository so that we ensure it is secure
sudo rpm –import https://jenkins-ci.org/redhat/jenkins-ci.org.key
If you get back to command prompt without any error then key download was successful
4. Do sudo yum update to ensure our package caches are uptodate and includes the latest repository information. Now we are ready to install Jenkins from our repository just downloaded. Part of the output post update would look like as given below:
5. Now execute sudo yum install Jenkins this will install Jenkins along with any dependencies
You should get the following message:
What this package installation does”
• Jenkins will be launched as a daemon on startup. See /etc/init.d/jenkins for more details.
• The ‘jenkins’ user is created to run this service. If you change this to a different user via the config file, you must change the owner of /var/log/jenkins, /var/lib/jenkins, and /var/cache/jenkins.
• Log file will be placed in /var/log/jenkins/jenkins.log. Check this file if you are troubleshooting Jenkins.
• /etc/sysconfig/jenkins will capture configuration parameters for the launch.
• By default, Jenkins listen on port 8080. Access this port with your browser to start configuration. Note that the built-in firewall may have to be opened to access this port from other computers. (See http://www.cyberciti.biz/faq/disable-linux-firewall-under-centos-rhel-fedora/ for instructions how to disable the firewall permanently)
• A Jenkins RPM repository is added in /etc/yum.repos.d/jenkins.repo
6. Jenkins package is going to rely on Java. So now we need to install Java(Approx 118 MB download).
sudo yum install java-1.8.0-openjdk
7. Verify that Jenkins installed successfully.
We need to connect TCP port 8080 so check if there is no firewall by systemctl status firewalld and systemctl status iptables
If you have firewall then we need to add this port
8. Now start the Jenkins by
systemctl start jenkins
systemctl status jenkins -l – (alphabet l) (to check it is running)
(Note: Systemctl is a systemd utility to control system and service manager. Systemd is a collection of software that provides building blocks for Linux OS. Systemd functions as central management and configuration platform for UNIX.)
9. Got AWS console. Select the security group created during EC2 instance creation and add the inbound rules for 80 and 8080
10. Go to your browser and type “PublicIPAddress:8080”
11. You will be asked to put admin password. Go to your Linux server from git bash and type following command:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
and you will see your password like this “1662fdb9075f4646bad79ac323a2bab4”. Copy this by CTRL+C and paste it in the password field in your browser.
13. After installation for plugin the following screen will appear, please make sure you remember your id and password as it will be required every time you want work with Jenkins.
14. You will get the following screen. Verify the IP address is matching with your public IP address, same will be in your url field. Click on Save and Finish.
Congratulations if you have seen the following screen, otherwise, google it for answers
Click on “Start using Jenkins” and you should see the following screen.