DevOps and IT Operations

Deploying Application using JENKINS

Introduction

The aim of this blog is to provide a guideline for to build sophisticated continuous integration and continuous delivery pipelines. The Continuous Integration will be performed by JENKINS and many of its plugins. Especially the pipeline plugins. Jenkins is the open source platform agnostic tool written in Java for implementing DevOps pipeline. It is supported by a vast and generous open source community who helps in upgrading the product frequently.

How does Jenkins Work?

Jenkins work by using various plugins for different activities. The below image provides a visual representation of plugins per activity in Jenkins.

Continuous Integration using Jenkins

Installation

In order to install Jenkins on Mac I used homebrew.

kinshukdutta@Kinshuks-MacBook-Pro-15 ~ % brew install jenkins                           
 Updating Homebrew...
 ==> Auto-updated Homebrew!
 Updated 2 taps (homebrew/core and homebrew/cask).
 ==> Updated Formulae
 Updated 1 formula.
 ==> Updated Casks
 Updated 1 cask.
 ==> Deleted Casks
 racket-cs
 

 ==> Downloading https://get.jenkins.io/war/2.279/jenkins.war
 Already downloaded: /Users/kinshukdutta/Library/Caches/Homebrew/downloads/48b5e6fad84c0f03e8caae8f2351cbf18e3420d38f1bc649118eac6a5ebde5d0--jenkins.war
 ==> /usr/local/opt/openjdk@11/bin/jar xvf jenkins.war
 ==> Caveats
 Note: When using launchctl the port will be 8080.
 

 To have launchd start jenkins now and restart at login:
   brew services start jenkins
 Or, if you don't want/need a background service you can just run:
   jenkins
 ==> Summary
 ?  /usr/local/Cellar/jenkins/2.279: 7 files, 73.1MB, built in 4 seconds

Starting Jenkins Server

kinshukdutta@Kinshuks-MacBook-Pro-15 ~ % brew services start jenkins
 

 ==> Successfully started `jenkins` (label: homebrew.mxcl.jenkins)

Configuration

In order to access Jenkins we will use Safari and try to hit the default port on the localhost. http://localhost:8080

Homebrew installed it without any authentication hence you will directly be able to access the landing page.

Jenkins localhost

On top right corner you can see an ! sign and a message. Click on it.

Jenkins – Information

Click the “setup security” button to set your login credentials.

Now we will change the security realm and will create the admin credentials to administer Jenkins.

Brew installs the Jenkins with the default plugins. However we need specific plugins for our activities. We will install some basic plugins that we are going to use in our sample configuration project. In order to do so, click on the the “Manage Jenkins” option on the left hand menu pane.

Now, click on the “Manage Plugins” option and click on the Available tab. That will show all available plugins. We will select the one that we might need.

  • Dashboard View: Customizable dashboard that can present various views of job information.
  • Build Pipeline PluginThis plugin renders upstream and downstream connected jobs that typically form a build pipeline. In addition, it offers the ability to define manual triggers for jobs that require intervention prior to execution, e.g. an approval process outside of Jenkins.
  • Copy Artifact PluginAdds a build step to copy artifacts from another project.
  • Git pluginThis plugin integrates Git with Jenkins.
  • GitLab PluginThis plugin allows GitLab to trigger Jenkins builds and display their results in the GitLab UI.
  • GitHub pluginThis plugin integrates GitHub to Jenkins.
  • LDAP PluginAdds LDAP authentication to Jenkins
  • Maven Integration pluginThis plug-in provides, for better and for worse, a deep integration of Jenkins and Maven: Automatic triggers between projects depending on SNAPSHOTs, automated configuration of various Jenkins publishers (Junit, …).
  • Bitbucket Plugin Integrates with BitBucket
  • OWASP Markup Formatter: Uses the OWASP Java HTML Sanitizer to allow safe-seeming HTML markup to be entered in project descriptions and the like.
  • Folders: This plugin allows users to create “folders” to organize jobs. Users can define custom taxonomies (like by project type, organization type etc). Folders are nestable and you can define views within folders. Maintained by CloudBees, Inc.
  • PipelineA suite of plugins that lets you orchestrate automation, simple or complex. See Pipeline as Code with Jenkins for more details.
  • Pipeline: Stage StepAdds the Pipeline step stage to delineate portions of a build.

Click on install without restart. And check the box that says “Restart Jenkins when installation is complete and no jobs are running”