Jenkins is an open source, free software automation server written in Java. Jenkins provides a wide range of plugins for building, deploying, testing and automating. For continuous deployments, Jenkins helps by speeding up processes such as building software or jobs ran by cron, monitoring, and execution of repeated jobs.
Jenkins automates the non-human part of the software development process with continuous integration and facilitating technical aspects of continuous delivery. Jenkins can be installed from Ubuntu packages using apt-get or you can download and run the application from Web Application Archive (WAR) files.
Jenkins supports version control tools, including CVS, Subversion, Git, Mercurial, RTC, etc. You can read more about this in the Jenkins Wiki. Weโll move forward with a step by step installation procedure and configuring Jenkins on Ubuntu 14.04 LTS.
Requirements
Configure Ubuntu 14.04 LTS and login as root or issue a โsudo su -
โ command to gain superuser privileges, so that you can perform basic installations and update your server with the latest packages. When the server is setup you are ready to move forward with next steps.
Letโs Start…
Before moving on to installing the packages on server, your system package manager needs to be updated. Run the following command to ensure your system package manager is up-to-date:
root@ubuntu:~# apt-get update
Install Java
Debian-based distributions like Ubuntu will install java with apt-get package manager. This is the easy way to install java with default packages for jre/jdk; execute the following commands:
root@ubuntu:~# apt-get install default-jre
To continue, type โYโ.
It will install Java Runtime Environment(JRE). If you need Java Development Kit (JDK), for compiling java applications run the following command:
root@ubuntu:~#sudo apt-get install default-jdk
Type โYโ to continue.
By executing those commands, java will be installed. When installing the latest version of Jenkins, you need to have Java 7 or above, and Java 8 is recommended. If you use the default commands shown above, the latest versions of Java will be installed, and you can skip the steps below and move onto the Jenkins installation.
Optional:
Some developers prefer using the Oracle JDK instead of OpenJDK. To install the Oracle JDK 7 or 8 execute this series of commands as root with apt-get:
apt-get install python-software-properties
add-apt-repository ppa:webupd8team/java
apt-get update
Depending upon your requirements, use the following commands to install:
Oracle JDK 7:
ย ย ย ย ย apt-get install oracle-java7-installer
Oracle JDK 8:
ย ย ย ย ย apt-get install oracle-java8-installer
While executing the above commands, it will show the required packages to be installed with Java โopenjdkโ. To continue with those packages, type `Yโ or โNโ to exit the installer.
This take few minutes to finish the installation.
Once your installation steps are completed, check the version of Java on the server and proceed to Jenkins installation.
root@ubuntu:~# java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
Installing Jenkins
Now you are ready to install Jenkins. Install the latest version of Jenkins so that you can take advantage of the latest fixes. Before doing that you need to add the key and source list for jenkins. Run the following commands:
root@ubuntu:~# wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | apt-key add -
When the key is added, you will get the โOKโ response. Next, add the source list:
root@ubuntu:~# echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list
When the keys and sources are added, update the system using apt-get to use a new repository before installing Jenkins.
root@ubuntu:~# apt-get update
Once the update is completed, you are ready for installation of Jenkins. Execute the following command on terminal; it will prompt for โYesโ or โNoโ. Type โYโ and your installation process will be started:
root@ubuntu:~# apt-get install jenkins
It will continue the installation and the daemon will start.
Now, the installation process is completed. To check the status of Jenkins service, run:
root@ubuntu:~# service jenkins status
It will display the status and running process ID(PID).
Jenkins Continuous Integration Server is running with the pid 16845
Voila! Your Jenkins is online and running.
By default, Jenkins runs on port 8080. If port 8080 is busy, you can switch ports by updating the default directory which is located at /etc/default/jenkins and update HTTP_PORT to 8081(HTTP_PORT=8081).
Configure Jenkins On The Web
After a successful installation of Jenkins, you need to configure its GUI on one of your favourite web browsers. You can access the server by using your ip address and port, like this:
http://localhost:8080 or http://your-ip-address:8080
You are able to see the display screen, which will ask for a password. Your password can be found in /var/lib/jenkins/secrets/initialAdminPassword. Enter the password in the โAdministrator Passwordโ field and click continue.
You should now see a โCustomize Jenkinsโ page where you will select how to install your plugins.
After installing your plugins, it will be time to create an admin account to log in to Jenkins.
Complete the required fields, and click on save and finish.
You now have successfully setup Jenkins and your brand new Jenkins server is ready for use!
Conclusion
Installing and configuring Jenkins can be daunting, but following the steps outlined in this post will make it easy and straightforward. This basic installation would be suitable for local use or on a private network. To run Jenkins on the public Internet, it would be wise to run it behind a reverse proxy that terminated SSL, either using a load balancer such as AWS ELB or using NGINX or Apache with Lets Encrypt for certificate management.
Naveen Vemuri
Related Posts
-
Integrating BDD Cucumber Test Suites in Jenkins in 3 Steps
Behaviour Driven Development improves communication between Developers, Testers and the product owners and over a…
-
Securing Jenkins on Mac OS X with Let's Encrypt
When using Jenkins to build iOS applications on Mac OS X, itโs very important to…