cover-img

Setting Up Jenkins CI/CD As Part of GitOps Implementation

2 September, 2023

2

2

0

👋 Introduction:

In the ever-evolving landscape of technology and software development, automation is the key to efficiency and productivity. In this blog, we delve into the world of automation with a focus on Jenkins, a powerful tool that streamlines CI/CD processes. Discover how to configure Jenkins, set up webhooks, and automate your workflows for smoother development and deployment.


🚀 Prerequisites:

  • an virtual machine
  • 🧐 Basic familiarity with Github , linux and Jenkins

📚 Step-by-step guide:

Install Jenkins :

Please follow the steps provided in the following link to install Jenkins on your specific operating system Link

Verify that jenkins service is running by running systemctl status jenkins

Screenshot 2023-09-01 at 9.06.28 AM.png

Access jenkins web interface on port 8080 , password can be found by running this command sudo cat /var/lib/jenkins/secrets/initialAdminPassword

Screenshot 2023-09-01 at 9.11.04 AM.png

sudo cat /var/lib/jenkins/secrets/initialAdminPassword

Add GitHub and Docker Hub credentials to Jenkins:

STEP-1 Click on Manage Jenkins:

Screenshot 2023-09-01 at 9.26.53 AM.png

STEP-2 Click on Credentials

Screenshot 2023-09-01 at 9.28.39 AM.png

STEP-3 Click on System

Screenshot 2023-09-01 at 9.29.16 AM.png

STEP-4 Click on Add Credentials

Screenshot 2023-09-01 at 9.29.52 AM.png

STEP-5 Add two credentials, one for GitHub and another for Docker Hub.

Screenshot 2023-09-01 at 9.33.55 AM.png

Jenkins Setup for DockerHub Image Updates:

Follow these steps to configure a job for testing, building, updating new image versions, and pushing them to DockerHub :

STEP-1 Create a new file in your app code repository named 'jenkinsfile.' Here's an example from my repository: link

Screenshot 2023-09-01 at 10.11.42 AM.png

STEP-2 Click on Add New item

Screenshot 2023-09-01 at 10.44.23 AM.png

STEP-3 Enter the item name 'Build-image' and select 'Pipeline'

Screenshot 2023-09-01 at 9.34.40 AM.png

STEP-4 Fill out below info , and click on save :

Screenshot 2023-09-01 at 9.56.29 AM.png

Jenkins Setup for K8s manifest Updates:

Follow the steps below to add an new job that updates K8s manifest repository file with the newest image from DockerHub:

STEP-1 Create a new file in your K8s manifest repository named 'jenkinsfile.' Here's an example from my repository: link

Screenshot 2023-09-01 at 10.00.10 AM.png

STEP-2 Click on Add New item

Screenshot 2023-09-01 at 10.44.23 AM.png

STEP-3 Enter the item name 'updatemanifest' and select 'Pipeline'

Screenshot 2023-09-01 at 9.57.47 AM.png

STEP-4 Add a new String parameter named 'DOCKERTAG' :

Screenshot 2023-09-01 at 10.02.53 AM.png

Screenshot 2023-09-01 at 9.59.03 AM.png

STEP-5 Fill out below info , and click on save :

Screenshot 2023-09-01 at 10.00.33 AM.png

RUN Jenkins jobs :

Run the 'Build-image' job, which will perform testing, building, and pushing the new image to DockerHub. Additionally, it should trigger the 'updatemainifestfile' job upon completion:

Screenshot 2023-09-01 at 11.25.22 AM.pngYou may get the following error :

Screenshot 2023-09-01 at 11.28.34 AM.pngTo fix the error we have to install 'docker-workflow' by going to "Dashboard > Manage Jenkins > Manage Plugins > Available (tab) > docker-workflow" :

Screenshot 2023-09-01 at 11.30.13 AM.pngRe-run the job, and it should run successfully:

Screenshot 2023-09-01 at 11.35.20 AM.png

Verify that the DockerHub image has been updated with the job number tag:

Screenshot 2023-09-01 at 11.38.45 AM.png

It should also automatically trigger the 'updatemainfest' job :

Screenshot 2023-09-01 at 11.44.20 AM.png

Verify that the K8s manifest repository file has been updated with the new image tag:

Screenshot 2023-09-01 at 11.39.13 AM.png

Configure a webhook in your app's code repository :

To automate the triggering of the Jenkins job, we need to configure a webhook in our app's code repository, allowing GitHub to send webhook payloads to the Jenkins server:

Screenshot 2023-09-01 at 11.55.36 AM.png

Conclusion:

Congratulations 🎉! You have successfully set up Jenkins CI/CD as part of the GitOps implementation. Now, when you push a change to your GitHub repository, it will automatically trigger the pipeline and deploy a new version of the app. Thank you for reading this blog

Next read:

📌 Creating AWS EKS Cluster using Terraform

📌 Setting Up ArgoCD with AWS EKS for GitOps Implementation

📌 Setting Up Jenkins CI/CD as part of GitOps Implementation ( Current Blog )


2

2

0

More Articles

Showwcase is a professional tech network with over 0 users from over 150 countries. We assist tech professionals in showcasing their unique skills through dedicated profiles and connect them with top global companies for career opportunities.

© Copyright 2025. Showcase Creators Inc. All rights reserved.