How to install Jenkins in Linux
Installation of Jenkins in Linux
Jenkins is an open source Java-based program with the packages for Windows, Mac OS X and other Linux operating systems. It runs in servlet Container(Tomcat, Glass fish) and is supported by more than 400 plugins. Installation of Jenkins is explained in this tutorial.
Run the command and check the version of java available in the system.
[root@linuxhelp1 ~]# java -version
java version " 1.7.0_51"
OpenJDK Runtime Environment (rhel-2.4.5.5.el7-x86_64 u51-b31)
OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)
To Install Jenkins
Enable the Jenkins repository
[root@linuxhelp1 ~]# wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
--2016-07-06 04:37:47-- http://pkg.jenkins-ci.org/redhat/jenkins.repo
Resolving pkg.jenkins-ci.org (pkg.jenkins-ci.org)... 52.202.51.185
Connecting to pkg.jenkins-ci.org (pkg.jenkins-ci.org)|52.202.51.185|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 71
Saving to: ‘ /etc/yum.repos.d/jenkins.repo’
100%[===========================================================================================> ] 71 --.-K/s in 0s
2016-07-06 04:37:48 (10.8 MB/s) - ‘ /etc/yum.repos.d/jenkins.repo’ saved [71/71]
Use the following command to download the key.
[root@linuxhelp1 ~]# rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
Install the Jenkins by using the following command.
[root@linuxhelp1 ~]# yum install jenkins -y
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
* base: centos.webwerks.com
* extras: download.nus.edu.sg
* updates: centos.webwerks.com
Resolving Dependencies
--> Running transaction check
---> Package jenkins.noarch 0:2.11-1.1 will be installed
.
.
.
Installed:
jenkins.noarch 0:2.11-1.1
Complete!
Once the installation of Jenkins completed add the Jenkins port to the Firewall as shown below.
[root@linuxhelp1 ~]# firewall-cmd --zone=public --add-port=8080/tcp --permanent success [root@linuxhelp1 ~]# firewall-cmd --zone=public --add-service=http --permanent success [root@linuxhelp1 ~]# firewall-cmd --reload success [root@linuxhelp1 ~]# firewall-cmd --list-all public (default, active) interfaces: eno16777736 sources: services: dhcpv6-client http ssh ports: 8080/tcp masquerade: no forward-ports: icmp-blocks: rich rules:
Start and check the status of the jenkins
[root@linuxhelp1 ~]# systemctl start jenkins [root@linuxhelp1 ~]# systemctl status jenkins jenkins.service - LSB: Jenkins Continuous Integration Server Loaded: loaded (/etc/rc.d/init.d/jenkins) Active: active (running) since Wed 2016-07-06 04:44:45 IST 19s ago Process: 43687 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=0/SUCCESS) CGroup: /system.slice/jenkins.service ??43702 java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/j... Jul 06 04:44:43 linuxhelp1 runuser[43688]: pam_unix(runuser:session): session opened for user jenkins by (uid=0) Jul 06 04:44:45 linuxhelp1 jenkins[43687]: Starting Jenkins [ OK ] Jul 06 04:44:45 linuxhelp1 systemd[1]: Started LSB: Jenkins Continuous Integration Server.
Open the browser and type http://< IP_address> :8080 or http://localhost:8080
Copy the path " /var/lib/jenkins/secrets/initialAdminpassword" in the home page and paste it in the terminal using your favourite editor to get the password.
[root@linuxhelp1 ~]# vim /var/lib/jenkins/secrets/initialAdminPassword
Bf30da956e2145178b84e950d3572608
Paste the password in the box. In setup wizard and choose “ install suggested plugins" .
Setup installation starts.
Create admin user by entering the user details and click " Save and Finish"
Click Start using Jenkins to explore Jenkins.
The dashboard of Jenkins appears.
Manage Jenkin option is used to configure system, configure global security, Global tool configuration, manage plugins etc
Select Configure Global Security to Enable Security and click Save to apply changes.
For managing plugin click on Manage plugin option.
AccuRev
CVS,
Subversion,
Git,
Mercurial,
Perforce,
Clearcase
RTC
You can:
Move a job from one installation of Jenkins to another by simply copying the corresponding job directory.
Make a copy of an existing job by making a clone of a job directory by a different name.
Rename an existing job by renaming a directory. Note that if you change a job name you will need to change any other job that tries to call the renamed job.
To start Jenkins manually open Console/Command line, then go to your Jenkins installation directory. Over there you can use the below commands:
To start Jenkins: jenkins.exe start
To stop Jenkins: jenkins.exe stop
To restart Jenkins: jenkins.exe restart