BACKGROUND IMAGE: iSTOCK/GETTY IMAGES
Jenkins is a tool that manages how a team compiles software code and pushes it out to users. Here are the introductory...
steps to Jenkins basics and how to install it.
Jenkins gathers code from developers on a team, runs unit and functional tests, and pushes the tested code and configurations out to target systems. Jenkins has been given the label DevOps, and its focus is not just infrastructure. When you install Jenkins, its role in the DevOps process starts one step before infrastructure, with code. A DevOps team can tack Puppet or a similar infrastructure-focused DevOps tool on the end of the Jenkins pipeline and make it run from within Jenkins.
Jenkins is Java-centric, although it can be used for Python, NodeJS and other languages. The concept of a build differs based upon the software language. You could say Python, for example, does not require the build step, but it still needs the package step.
To build software, a system must pull code from a repository and, in the case of Java, compile it and then package it as a JAR file. The JAR file includes all of the compiled objects (classes) that make up the target application. Then, Jenkins pushes the JAR file onto the file system of a Java application server, such as Apache Tomcat, which makes the file available to end users via a web server, using a browser or mobile app.
Jenkins basics and what it can do
Jenkins suits the needs of a medium or even a large team of developers. Each member of the team checks their code into a code repository, such as GitHub or Subversion. Jenkins responds to changes in the code repository to kick off the build. Or, Jenkins runs on a schedule. The build flushes out any errors found in any individual programmer's code, as well as conflicts between developers' code changes in the larger application.
Jenkins does not push code out onto the target environment until that new code passes unit, functional and, optionally, volume tests.
These tests work from Jenkins as well. Developers and testers write them in, for example, Ruby, using Cucumber, Selenium or a similar framework. Unit tests execute code-level tests to check subroutines or other elements. Functional tests execute a larger scenario that tests a whole program, such as by mimicking keystrokes from a user. Additional functional testing can be done manually by specialized analysts who run those scenarios.
Jenkins basics can also include configuration management scripts and programs, written in Salt, Ansible, Puppet, Chef or another tool, to do tasks such as spin up a farm of VMs or Docker containers for the load test and then shut them down or build virtual networks, configure storage and implement other infrastructure setups.
The automated, end-to-end approach Jenkins takes makes it ideal for CI/CD and Agile software projects. That's another reason why people call it a DevOps product.
As is often the case with open source software, Jenkins' creators opened a commercial enterprise based on the open source technology. CloudBees provides commercial, supported options, in the form of CloudBees Jenkins Enterprise or the less expansive CloudBees Jenkins Team.
How to install Jenkins
Jenkins has grown to a vast user base, with more than 1,300 plug-ins. The system can scale by running on a Kubernetes cluster, which means it can run on many machines instead of one. There is also a plug-in for Atlassian Jira, which many Agile project teams use to track issues and assign tasks.
The GUI helps illustrate the Jenkins basics discussed earlier. To install Jenkins, download the WAR file (a JAR file packaged for web application servers) and run:
java -jar jenkins.war
Look at the console where you ran the Java JAR command to get the initial password for the admin user. Then, open the GUI. There is no need to do any configuration to get the plain version of Jenkins up and running.
From the main screen of Jenkins (Figure 1), create a new pipeline, which is a series of steps to achieve an end result.
Jenkins' purpose is to execute various kinds of scripts. For Java projects, the first step is usually Apache Maven or Ant, which are config files that show the dependencies Java programs need. Jenkins should include those, compile the Java class files and then build the JAR file that is the completed program (Figure 2).
As each step runs, it creates environment variables, such as a password or some other element needed by a subsequent step. The user can include test scripts in the build to verify that the code is ready to move to the next step. Dependencies exist between phases so that the build stops when there is a problem.
The Jenkins install can also include provisioning tools, such as Ansible, to configure and launch software and containers, VMs, networks or other infrastructure. The user configures all these steps from the Jenkins dashboard. Large development groups even project the Jenkins build console onto a shared screen so programmers collectively track whether the build is red (something does not work), green (it does work) or still in progress (another color). Sometimes, a team using Jenkins will split off the volume test to make the build run faster, such as for testing everything but its performance under load.