In IT we often talk about the importance of computing time. Initially, that was the main focus. To get the programs to run as fast as we possibly can.
In fact, when you rent a VPS, this compute time is what you are paying for, in 2017 we have come to realize that this price is not that high after all.
We have come to the realization that programmer time is way more expensive than computer hardware. Your developers should not focus on repetitive mundane tasks but rather exert every ounce of creative into actual development.
Repetitive tasks like compiling or building the entire software from source. Managing commits, making it go through all the test cases and then finally pushing it onto the production server all of this can be automated to suit your organization’s workflow.
Jenkins offers a good solution of this entire rigmarole and is popularly known as a Continuous Development and Continuous Integration (CDCI) solution.
Prerequisites
The following setup has been tested on a VPS with the following attributes:
- VPS with a static IP and CentOS 7.3 (64-bits)
- Root access to the same VPS
Installing Jenkins on a CentOS VPS
First, we need to get the only dependency we need to get Jenkins to take off, and that is Java (more precisely, Java8)
$sudo yum install -y java
Installing Jenkins is really as simple as fetching the package info to your environment along with the necessary cryptographic key.
$sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo $sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
Following the above to command, we can now install jenkins as a typical package.
$sudo yum install -y jenkins
That is all there is to installing Jenkins, and now it is time to actually start running Jenkins.
Initial SetUp
We begin with starting up the Jenkins service by running the command:
$sudo systemctl start jenkins.service
After this, you may want to check if the service is actually running as it is meant to. To check this, run:
$sudo systemctl status jenkins
For the first time installation of Jenkins, a typical output may look like the screenshot below.
Once you see the active (running) prompt it is time to start using the Web UI. Open your web browser and visit http://ip_address:8080
. Jenkins’ dashboard is accessible via the public IP on port 8080
.
For the first time you login, you would be asked to unlock it, the password so let’s get it from the path that is shown in the screen.
$cat /var/lib/jenkins/secrets/initialAdminPassword
You can copy the output and use it to proceed with the Initial Set Up
Here you may want to want to click on ‘Select plugins’ before installing them because Dashboard is not a part of ‘Suggested Plugins’, so click on the right button to select plugins.
The dashboard view is not selected by default, you may want to select that and review other plugins as per the need of your organization. In this example, we would keep the list of other selected plugins as is, and click on install. It may take a while but eventually, all the plugins would get installed.
After this is done, you will be asked to set up your admin user and credentials. With that done, you are pretty much ready to import your existing software project or start a new one with Jenkins.
Useful Features and important points
Being centered almost entirely around CDCI, Jenkins integrates well with GitHub and SVN repositories, has support for containerization using Docker. It can be made to automate the build process of your project and also perform important actions like mailing related individuals every time a build is deployed. Let’s start by building a simple project, by either clicking on create new jobs or New Item:
It will then ask to enter the project name and select a type of project from the options listed below. In our example, the project is New Project which is of type freestyle.
After this, you will be asked to give a general description of the project
Now, if you scroll a little further, you will see build options as well, this can be a list of scripts to automate your entire build process, or it can call upon any IDE to do the heavy lifting.
Let’s select execute shell option and add a simple echo statement as shown below
You can also set Post-build actions to send you email notifications every time there is a new build that succeeded or failed.
Note: If you don’t get something that you need for example an option for GitHub Project or SVN project, click on Manage Jenkins and from there to Manage Plugins to look for the right option.
Click Save and Jenkins will redirect you to the project screen where you can see various details as shown below:
Clicking on Build Now will add an entry to the build history section (which is empty right now) on the bottom left corner of the screen.
Click on the #1
Here you can see various details about the build, what changes were introduced by which developer and if you click on the Console Output, you can see how your build script was executed and what were the consequences of it.
Conclusion
The only entry-level barrier with Jenkins is that it makes little sense to individuals who have no experience with enterprise-grade software development and management in the first place. The trick is to stay pragmatic and use Jenkins to learn about proper software development and not the other way round.
We hope you have enjoyed reading this post setting up Jenkins on CentOS. Feel free to reach out to our support crew in the case of any issues, we offer 24/7 WordPress support at a ridiculously low price. If you liked this article, then please subscribe to our mailing list for WordPress video tutorials. You can also find us on Twitter and Facebook.