Day 31:Complete Jenkins Project

Day 31:Complete Jenkins Project

Jenkins CI/CD project

Quick recap

In the previous post https://aminchivilkar.hashnode.dev/day-30exploring-jenkins we delve into accessing Jenkins via the user interface on a local machine, unlocking it, and fetching code from GitHub.

Beginning with Familiar Steps:

As true pioneers, we kick off by unlocking the gates of Jenkins once more. Our trusty initial admin password is the key to the kingdom.

The next task follows the same as the previous steps, but change the execute shell command as below :

Building the Magic:

it plays and watch as the stage is set for Docker's performance.

Encountering an Error:

Our Console Output surprises us with an error: "Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock."

Unveiling the Solution:

The issue? the above error shows that jenkins has not been added to the docker group. Fear not, we have a solution up our sleeves.

Command Revelation:

Using sudo cat /etc/group, we uncover the group-docker's lineup, missing Jenkins.

sudo cat /etc/group

gnome-initial-setup:x:993:
amin:x:1000:
docker:x:1001:amin
mysql:x:130:
jenkins:x:131:

Jenkins Joins In:

We make Jenkins an official Docker group member, transforming its status by adding Jenkins to the group- docker using below commands and this should solve the first problem:

sudo usermod -aG docker jenkins
sudo cat /etc/group

gnome-initial-setup:x:993:
amin:x:1000:
docker:x:1001:amin,jenkins
mysql:x:130:
jenkins:x:131:

sudo reboot # this will restart the linux system or restart EC2 instance
if connected via AWS

The Reboot:

A simple sudo reboot solidifies Jenkins' relationship with Docker.

Once the system is rebooted, the problem should be solved as mentioned below:

Switch Command:

We will again change the execute shell command as below :

Killing and Rerunning:

We take a step by stopping Docker and hitting that play button again.

But first we will kill the docker and then again rerun using the play button:

Victory Lap:

And there it is! The run is successful, a testament to Jenkins and Docker's newly found harmony.


Conclusion :

From Jenkins' unlocking to Docker's triumphant run, our journey continues. Automation and efficiency await, and each command leads us closer to DevOps mastery.

Hope you like my post. Don't forget to like, comment, and share.