DevOps Tools Deep Dive — Hands-on

Rangaraj Balakrishnan
10 min readJul 4, 2024

--

INTRODUCTION

Embark on a journey into the world of Jenkins — an open-source automation server that streamlines the Continuous Integration (CI) and Continuous Delivery (CD) pipelines. This comprehensive guide will walk you through the installation process on a Linux environment, unraveling the power of Jenkins for seamless software development.

What is Jenkins?

Jenkins, a key player in the CI/CD landscape, empowers developers by automating building, testing, and deployment processes. Its extensibility through plugins makes it a versatile tool for orchestrating the software development lifecycle.

Key Features of Jenkins:

  1. Automation Hub: Jenkins serves as the automation hub for building, testing, and deploying code changes. Its extensible nature allows integration with various tools and technologies.
  2. Versatility through Plugins: The richness of Jenkins lies in its extensive plugin ecosystem, facilitating seamless integration with version control systems, build tools, and deployment platforms.
  3. Scalability: Whether it’s a small-scale project or a large enterprise application, Jenkins scales effortlessly to meet diverse development needs.
  4. Community Collaboration: Being open-source, Jenkins benefits from a vibrant community. Continuous improvements and an active community ensure Jenkins stays at the forefront of CI/CD innovation.
  5. Customizable Workflows: Jenkins allows the creation of complex build and deployment pipelines through its intuitive graphical interface, providing flexibility to tailor workflows according to project requirements.

In essence, Jenkins is not merely a tool; it’s a robust platform empowering development teams to achieve higher efficiency, reliability, and agility in their software delivery processes. By automating repetitive tasks, Jenkins enhances collaboration and accelerates the pace of software development.

Installation Steps:

To start this hands-on lab,you need following resources.

  1. Google cloud (or any other cloud or some VM’s from your local machine).
  2. Jenkins VM should have 2 CPU / 4 GB memory / 40 gb Disk. Install ubuntu LTS linux in this machine.
  3. Make sure you have root access or root login credentials.
  • Step 1 : Install prerequisite software packages
  • Step 2 : Configure environment variables
  • Step 3: Configure Jenkins Software Repository
  • Step 4: Configure Jenkins Key
  • Step 5: Install Jenkins
  • Step 6: start the Jenkins Service Persistently
  • Step 7: Install the necessary plugins
  • Step 8: Global Tools Settings — In Jenkins Console — JAVA , MAVEN, GIT
  • Step 1 : Install prerequisites software packages
apt update
apt install fontconfig openjdk-17-jre
apt install vim wget  git -y
wget https://dlcdn.apache.org/maven/maven-3/3.9.8/binaries/apache-maven-3.9.8-bin.tar.gz
tar xvf apache-maven-3.9.8-bin.tar.gz
mv apache-maven-3.9.8  /usr/local/apache-maven
  • Step 2 : Configure environment variables
vim ~/.profile
  • In this file
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64/
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export M2_HOME=/usr/local/apache-maven
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
vim /etc/environment

:/usr/lib/jvm/java-17-openjdk-amd64/bin:/usr/local/apache-maven/bin:"

now

source ~/.profile
  • Check Maven Build Tool Version
mvn -version
java --version

Till still step follow for the both Jenkins and tomcat machines

  • Step 4: Install jenkins
sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \
https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
echo "deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc]" \
https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
/etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt-get update
sudo apt-get install jenkins
  • Step 6: start the Jenkins Service Persistently
systemctl enable jenkins
systemctl start jenkins
systemctl status jenkins

Access Jenkins Console

— Get the external ip from gcp machine for jenkins

http://<jenkins Server IP >:8080/

→ Unlock Jenkins:

Retrieve the initial admin password.

cat /var/lib/jenkins/secrets/initialAdminPassword

Add the password in the below box :

Access the Jenkins at http://your_server_ip:8080, paste the password, and follow the setup wizard.

http://35.184.130.5:8080/

access jenkins admin console

- Step 7: Install the necessary plugins

The following plugins needs to be installed

  • dashboard view
  • Build Pipeline
  • Deploy to container
  • maven integration
  • Email Extension Template

to install plugins go to manage plugins

Global Tools Settings — In Jenkins Console — JAVA , MAVEN, GIT

configure Jenkins Global variables

  1. variable 1 — JAVA

in Jenkins console go to manage jenkins → Click Tools

Add JDK

Note : to know the JAVA version go to ur jenkins server login ssh prompt and run below command

java --version

JAVA_HOME is /usr/lib/jvm/java-17-openjdk-amd64/

uncheck

variable 2 — MAVEN

variable 3 — GIT

Now save it

TOMCAT Installation

To start this handson lab,you need following resources.

  1. Google cloud (or any other cloud or some VM’s from your local machine).
  2. Tomcat VM should have 2 CPU / 4 GB memory / 40 gb Disk. Install Tomcat in **Ubuntu 20 LTS OS machine.
  3. Make sure you have root access or root login credentials.
  4. For this Tomcat and Artifactory VM you must have 2 CPU and minimum 7.5 GB memory.Create this VM with **Ubuntu 20 LTS OS ** OS machine
  • Step 1 : Install pre-requisite software packages
  • Step 2 : Configure environment variables
  • Step 3: Configure TOMCAT Software Repository
  • Step 5: Change Java Heap Size
  • Step 6: Install TOMCAT Web Application server
  • Step 7: Restart Tomcat Services
  • Step 8: Create new pipeline and enable manual deployment to deploy application in tomcat web application server
  • Step 9: Create new pipeline and enable auto deployment to deploy application in tomcat web application server

TOMCAT

  • Step 1 : Install pre-requisite software packages
apt update
apt install fontconfig openjdk-17-jre
apt install vim wget  git -y
wget https://dlcdn.apache.org/maven/maven-3/3.9.8/binaries/apache-maven-3.9.8-bin.tar.gz
tar xvf apache-maven-3.9.8-bin.tar.gz
mv apache-maven-3.9.8  /usr/local/apache-maven
  • Step 2 : Configure environment variables
vim ~/.profile
  • In this file
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64/
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export M2_HOME=/usr/local/apache-maven
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
vim /etc/environment

add :/usr/lib/jvm/java-17-openjdk-amd64/bin:/usr/local/apache-maven/bin in this file.it looks like below

now

source ~/.profile

Check Maven Build Tool Version

mvn -version
java --version

Step 6: Install TOMCAT Web Application server

mkdir /usr/local/tomcat 
sudo wget https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.90/bin/apache-tomcat-9.0.90.tar.gz
sudo tar xvf apache-tomcat-9.0.90.tar.gz --strip-components=1 -C /usr/local/tomcat
sudo ln -s /usr/local/tomcat/apache-tomcat-9.0.90 /usr/local/tomcat/tomcat
sudo useradd -r tomcat
sudo chown -R tomcat:tomcat /usr/local/tomcat

Configure the tomcat service

vim /etc/systemd/system/tomcat.service
[Unit]
Description=Apache Tomcat Web Application Container
After=network.target
[Service]
Type=forking
User=tomcat
Group=tomcat
Environment="JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64"
Environment="JAVA_OPTS=-Djava.security.egd=file:///dev/urandom -Djava.awt.headless=true"
Environment="CATALINA_BASE=/usr/local/tomcat"
Environment="CATALINA_HOME=/usr/local/tomcat"
Environment="CATALINA_PID=/usr/local/tomcat/temp/tomcat.pid"
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC"
ExecStart=/usr/local/tomcat/bin/startup.sh
ExecStop=/usr/local/tomcat/bin/shutdown.sh
[Install]
WantedBy=multi-user.target

save the file and exit.

Now run the below commands

systemctl daemon-reload
systemctl enable tomcat
systemctl start tomcat
systemctl status tomcat

vim /usr/local/tomcat/conf/tomcat-users.xml
<role rolename="tomcat"/>
<role rolename="manager-gui"/>
<user username="tomcat" password="s3cret" roles="tomcat,manager-gui,manager-script"/>

Save the file and exit

comment the lines in the below file

vim /usr/local/tomcat/webapps/manager/META-INF/context.xml
<!-- <Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" /> -->

save the file and exit.

Now run the below commands

systemctl daemon-reload
systemctl enable tomcat
systemctl stop tomcat
systemctl start tomcat
systemctl status tomcat

now access the tomcat admin url

  • access tomcat console

http://:8080/

  • click manager App icon
  • username — tomcat
  • password — s3cret

Open tomcat console and download gameoflife.war file.deploy manually

Step 8: Create new pipeline and create war file manually

Dashboard>Al

save it

then left side menu click → build now

see the above screenshot The war file has been created into /var/lib/jenkins/workspace/Manual war file build/webapp/target/webapp.war directory

this is manually we have created this war file

Let us go and deploy this war file to tomcat automatically using pipeline

Step 9: Create new pipeline and enable auto deployment to deploy application in tomcat web application server

for this POC use https://github.com/rangarajbk/hello-world-jenkins.git

save and in the left side click build now option

now see the output in the below screen.

in the above screenshot ,the war file getting created using maven build and then jenkins is deploying this war file from jenkins server to tomcat server.

Deployment is success.

Let us check the tomcat weather application [ war file ] is deployed or not ?

Access tomcat admin console — http://35.184.250.178:8080/manager/html

see the above screenshot.Webapp.war application has been deployed.

right click webapp and open new tab in the same browser

Now we need to integrate colloboration tools called slack.

what is the use of slack collaboration tool in jenkins environment ?

before slack integration create a slack account and create slack workspace

click start with free

create a public channel called #alert-support-teams

go to manage apps.see screenshot below

search incoming webhooks

click add to slack

in the above screenshot click add incoming webhooks integration

copy the webhook url in the notepad++

https://hooks.slack.com/services/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

split the url url + passkey

url — https://hooks.slack.com/services/

passkey — T078VRU5R5M/B079CTCETL4/aSmVKFxwx7BBbimqbYrVK8V6

Now go to jenkins and first install slack plugin

now slack plugins are installed without any issues

now integrate slack to jenkins first

Then save it

see now in your slack there is no message in the #alert-support-teams channel

now go to jenkins and test the intergation connectivity between jenkins and slack colloboration tool

go to slack and see the logs

in the above screenshot u are seeing the updates.

now we are going back to auto-deploy jenkins pipeline and integrate this slack channel.

let see what happens

now we are inside auto-deploy jenkins pipeline.In this pipeline we seen already how we configured the auto deployment from build,compile and deploy to tomcat server.

Now click configure option from the left side menu

click build now option in the left side menu

Conclusion:

Congratulations! You’ve successfully installed Jenkins, laying the foundation for efficient CI/CD pipelines. Harness the power of automation and collaboration with Jenkins on Linux, paving the way for faster and more reliable software development.

--

--

Rangaraj Balakrishnan

Infrastructure Architect | Cloud Architect | Database Architect | Blogger- Oracle 14x | GCP 2x | Azure 2x | AWS 3X | CIPPE Certified | ITIL Certified