Building the DevOps Pipeline with Jenkins

0
5361

Jenkins is an open source tool that provides integration with the tools used in application lifecycle management to automate the entire process, based on feasibility.

Figure 1: Customise plugins
Figure 2: Admin user

The prerequisites for installing Jenkins on a specific system are:

  • Jenkins official documentation recommends 256MB of RAM.
  • Jenkins official documentation recommends 10GB of drive space; however, I suggest 50GB – 80GB of free space on a disk drive.
  • Jenkins official documentation recommends Java 8 or 11.

The commands to run Jenkins are as follows.
You can start Jenkins at the command line by using the Generic Java package (.war):

java -jar jenkins.war

To access the Jenkins dashboard, browse to http://localhost:8080. Change the port to run Jenkins, with the following command:

java -jar jenkins.war --httpPort=9999
Access Jenkins’ dashboard: Browse to http://
localhost:9999

It will redirect the user to unlock the Jenkins page by providing the administrator password, which can be found from the console log when the jenkins command is executed for the first time.

Figure 3: Jenkins instance configuration
Figure 4: Jenkins dashboard

Click on Install Suggested Plugins.

Once all the plugins are installed, create your first admin user (Figure 2) and click on Save and Continue.

Provide the Jenkins URL or keep the default, depending on your needs.

Once the Jenkins setup is complete, click on Start using Jenkins. Verify the Jenkins dashboard. Click on Manage Jenkins.

Go to Manage Jenkins -> Global Tool Configuration.

The Build Pipeline plugin
Using Jenkins and the build pipeline makes us realise the complexities of managing Jenkins over time. It is easier to use the Build Pipeline plugin in Jenkins to create pipelines with upstream and downstream projects (Figure 6).

Execute the pipeline as shown in Figure 7.

Figure 5: Global Tool Configuration
Figure 6: Upstream and downstream projects

Scripted pipelines
Jenkins 2.0 and later versions have built-in support for delivery pipelines. Jenkinsfile contains the script to automate application life cycle management activities. There are two types of pipelines in Jenkins, as of today. This means that Jenkinsfile can contain two different types of styles/syntax and yet it can achieve the same thing.

Scripted pipelines follow the imperative programming model. They are written in the Groovy script in Jenkins. All Groovy blocks/constructs help to manage flow as well as error reporting.

node {
/* Stages and Steps */
}
node {
stage(‘SCA’) {
// steps
}
stage(‘CI’) {
// steps
}
stage(‘CD’) {
// steps
}
}


Figure 7: Build Pipeline plugin

Figure 8: Blue Ocean plugin

Declarative pipelines
As the name suggests, a declarative pipeline follows a declarative programming model. Declarative pipelines are written in a domain-specific language in Jenkins that is clear and easy to understand.

pipeline {
agent any
stages {
stage(‘SCA’) {
steps {
//

}
}
stage(‘CI’) {
steps {
//
}
}
stage(‘CD’) {
steps {
//
}
}
}
}

Open the Blue Ocean dashboard and click on Create Pipeline. Connect with the required repository; then create stages, select the steps and configure.

Figure 9: Blue Ocean repository
Figure 10: Blue Ocean tests

Blue Ocean is a new user experience, and it provides an easy way to access unit test results (Figure 10).

Click on Pipeline to get the status of the pipeline. Click on the specific stages to access the logs of these stages.

Figure 11: Blue Ocean automated deployment
Figure 12: Blue Ocean artifacts

Click on Artifacts to access the package file and other artifacts (Figure 12).

The following list of open source tools can be integrated in the pipeline to implement DevOps practices.

Tool Description
Travis CI Hosted continuous integration service that supports integration with BitBucket and GitHub. https://travis-ci.org/
GoCD GoCD is a build and release tool that helps to perform end-to-end orchestration for application life cycle management activities.
https://www.gocd.org/
Nagios Nagios is an open source tool that can be used to monitor network and infrastructure. https://www.nagios.org/
Docker This is a very popular container management tool. Kubernetes supports Docker as a container provider. https://www.docker.com/
Ansible Ansible is used for automation, such as for configuration management and continuous delivery. https://www.ansible.com/
Collectl This is used to gather the performance data of systems such as CPU, network, and data. http://collectl.sourceforge.net/
GitHub This provides a repository for public and private access to maintain version control. It is hosted. https://github.com/
Kubernetes This is one of the most popular container orchestration tools available in the market. https://kubernetes.io/
Artifactory This provides community and enterprise versions of artifact management tools. http://www.jfrog.com/artifactory/
CruiseControl CruiseControl is a Java based, open source continuous integration framework. http://cruisecontrol.sourceforge.net/
Selenium Selenium is a popular automated functional testing tool that is used for Web applications. It is open source. https://www.selenium.dev/
Appium Appium is a popular automated functional testing tool that is used for mobile applications. It is open source. http://appium.io/
SonarQube This is used to analyse the code to track bugs, security vulnerabilities, and code smells. It supports more than 15 programming languages.
https://www.sonarqube.org/
SaltStack https://www.saltstack.com/
Apache JMeter https://jmeter.apache.org/
OWASP ZAP This is used to scan security issues of applications for penetration testing. It is an active open source Web application security scanner.
https://www.zaproxy.org/
Ant Apache Ant is an XML based build management tool for Java based projects. https://ant.apache.org/
Gradle This is a popular build management tool for Android based projects. It is also used in Java based applications. It supports domain-specific languages. https://gradle.org/
Maven Apache Maven is one of the most popular build tools, with multiple goals for an application’s life cycle phases such as build, test, and deploy. It is mainly used for Java projects.
http://maven.apache.org/
Hygieia This is a one-of-a-kind DevOps dashboard that helps to integrate with tools such as Bamboo, Jenkins, Jenkins-codequality, Jenkins Cucumber, Sonar, AWS, uDeploy, XLDeploy, Jira, VersionOne, Gitlab, Rally, Chat Ops, Score, Bitbucket, GitHub, Gitlab, Subversion, GitHub GraphQL, HP Service Manager (HPSM), AppDynamics, Nexus IQ and Artifactory. It has two types of dashboards — one for engineers and the other for executives.
https://www.capitalone.com/tech/solutions/hygieia/
CFEngine This is a popular DevOps tool that is used to automate IT infrastructure related operations. https://cfengine.com/
GitLab This is a Git repository. Now it also provides support for automation pipelines to configure continuous integration and continuous deployment.
https://about.gitlab.com/
Junit This is a popular yet simple unit testing framework to write unit tests for the Java programming language.
https://junit.org/
Jasmine Jasmine is a popular behavioural data driven framework to verify JavaScript based applications. http://jasmine.github.io/

LEAVE A REPLY

Please enter your comment!
Please enter your name here