Overcoming Doubts and Finding Satisfaction: My Journey Building a CICD Pipeline

Overcoming Doubts and Finding Satisfaction: My Journey Building a CICD Pipeline

Hello everyone,

Last week I was making my first DevOps project which is available on youtube on the Technical Guftgu channel (https://youtu.be/vfw8zXyJtQA). For this project, I had to download and run Git, Java, Tomcat, and Ant on my Windows system. I also had to add Java and Tomcat to my Windows system and environment variable. I followed all the steps, and also installed and ran Jenkins on Tomcat. But while working in Jenkins I was unable to connect my Git repo to Jenkins as it was giving me some unusual error (At this instance I don't have a screenshot to show of that error). I tried to resolve that error but failed, invested several hours jumping through various Youtube videos, google posts, and Chatgpt but failed at last.

While surfing I came across another project by TrainWithSumit(https://www.youtube.com/live/nplH3BzKHPk?feature=share) on youtube and started to build that and I successfully built it (https://www.linkedin.com/posts/srijan-maurya100258_devops-continuousintegration-continuousdeployment-activity-7085262698732560385-YGw5?utm_source=share&utm_medium=member_desktop).

Coming to the present...

Today I decided to build another project. So I decided to build my first project again but as of the last time I had failed to run it on Windows I decided that now this time I will do it on aws instance. It was a difficult task for me as in the tutorial my instructor had built that project on Windows and the configuration which were required and which he was doing on Windows was difficult for me to do on aws instance, but I motivated myself and decided that I will give a try (ज्यादा से ज्यादा क्या होगा, नहीं चलेगा).

Outline of my Project:

My task was to make a complete CICD pipeline:

My project would start from a GitHub repo (https://github.com/Professor-006/SampleWebApp.git) when my Jenkins would pull the code from GitHub during executing its job githubpull. Then it would build and review the code in its second job. In its third job it would test it and at last, it would deploy the job on the Tomcat server from where we could easily excess and run it.

The work begins

Then I started to set up an AWS machine-

  • Signed in to the AWS Management Console at console.aws.amazon.com.

  • Opened the Amazon EC2 console.

  • Clicked on "Launch Instance" to start the instance creation process.

  • Then configured all the requirements necessary for my instance to run.

  • Once the instance was launched, I connected it with the help of Putty.

  • Now I was connected to my Amazon Linux machine.

Next, I updated It. Then I started to install all the necessary applications that were required for my project.

Installing and running Tomcat

As an experience, I was aware of how to install and run Tomcat on Windows but running it on Linux was completely new for me. I went on the Tomcat website to search for the setup link but seeing too many links, I got confused about which one to download and was unable to understand the documentation too!

So, I decided to visit search for the installation process on youtube and came across a really helpful video (https://www.youtube.com/watch?v=1bnla8eYcaI). I followed all his steps, changed the tomcat port number and finally, I was ready with my tomcat successfully running it on Chrome. Below is the command for it.

yum install java -y
wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.78/bin/apache-tomcat-9.0.78.tar.gz to 
# link to download it from internet
tar zxvf apache-tomcat-9.0.78.tar.gz #extracting the tar file
ls
cd apache-tomcat-9.0.78/
cd bin/
ls
sh startup.sh #starting tomcat

But when I tried to access the Manager App section I got a 403 error.

For this, I tried to read and understand the error and resolved it, as it said but still Manages App was inaccessible then I decided to check for a solution on Youtube. I can across a video where I got the solution to the error (https://www.youtube.com/watch?v=cukABJi3ce4).

The instructor directed me first to this file -

vi /home/ec2-user/apache-tomcat-9.0.78/webapps/manager/META-INF/context.xml

He asked to comment out few lines of code-

Then in the tomcat-user.xml file I had to add the username and password:

vi /home/ec2-user/apache-tomcat-9.0.78/conf/tomcat-users.xml

After doing this I restarted my Tomcat server and now this time the Manager App was accessible.

Running Jenkins on Tomcat server.

After running Tomcat on Linux my next task was to run Jenkins on my Tomcat. For this, I went to the official website of Jenkins and downloaded the war file of Jenkins on my Linux using the wget command :

Then moved that set-up to -

mv jenkins /home/ec2-user/apache-tomcat-9.0.78/webapps

After doing this I returned to the Tomcat window on my browser and saw that Jenkins was successfully running on my Tomcat server.

Coming here was a big accomplishment for me because everything I was doing was completely new for me and things by luck for me were going smoothly.

Configuring Jenkins

To access Jenkins, on my browser, I typed <instance ip public address>:8020/Jenkins

On the startup window, I was asked for the secret password, and the location link was also given. I drove through that link and easily got through that password and entered it. Then I configured the whole Jenkins It took about 10 mins and then I was on the Jenkins dashboard window.

The real battle begins

Now the time had come that I had to build jobs so that the project could be done.
So I started creating projects and one by one I created four of them connecting them in a pipe-formation

After every job was fully configured the last part was to build the CICD pipeline. So, for that, I created New View, installed the required CICD plugin and configured it connecting the githubpull it. My objective was that when the pipeline would start it would start from githubpull job than on successful execution buildandcode Review would run on successful execution unittest would run and at last after its successful execution deploy would run, thus creating a complete pipeline.

Final result

When everything was ready I finally ran the CICD pipeline at first everything worked fine the first job executed successfully but the third job showed some errors at that point of time I was a bit surprised that why it happened I rechecked it everything was file. Now since my third job had failed so the fourth job did not run. I tried to figure out the error that had occurred in the third job but nothing got into my head.

Then I ran the fourth job manually and to my surprise, this job too showed some error. I reviewed the error this time the error got into my head. The error said that it had built the code successfully but was unable to deploy it on the Tomcat server. I tried a few things so that I could make it work but failed.

At last, while I was reviewing the error I found that it was successfully built and its war file was located on my machine its location was also given:

I went there and found the samplewebapp.war file. One thing I understood that once that was file will be uploaded on the Tomcat server it will run so I copied the war file to the Tomcat webapps location where I had moved the Jenkins.war file. Once after doing this, I open the browser and found the app to be successfully running I opened it on my browser and it worked perfectly.

Hence at last this would have been the output if the pipeline had worked correctly:

Despite the outcome of my project not meeting my expectations, I found immense satisfaction in the fact that I was able to persevere and accomplish it single-handedly after putting in hours of hard work. What truly mattered to me was the pure joy I experienced throughout the entire process. There was a moment when doubts crept in, and I considered that I would be not able to install Tomcat, but against all odds, I forged ahead and ran the pipeline!

This was the outcome of my pipeline:

Thank you for your time and do share your thoughts.