Day 27 Jenkins Declarative Pipeline with Docker

ยท

2 min read

Table of contents

Introduction

Creating a comprehensive Jenkins CI/CD project with thorough documentation is a vital step in modern software development. Such a project not only accelerates the delivery of high-quality software but also fosters collaboration and repeatability among development teams. This guide will delve into the process of setting up an end-to-end CI/CD pipeline using Jenkins for a Node.js web application. The documentation will provide an insightful roadmap for newcomers and serve as a handy reference for experienced developers.

I created a simple declarative pipeline for Hello World. Now Today we will create a pipeline for the Django application.

Task:

  • Create a docker-integrated Jenkins declarative pipeline

  • Use the above-given syntax using sh inside the stage block

  • You will face errors in case of running a job twice, as the docker container will be already created, so for that do task 2

Follow a few steps to create a declarative pipeline.

  1. login into the Jenkins dashboard and click on CREATE A JOB

  1. Enter the job/item name and select PIPELINE PROJECT.

  1. Give the description of this job and copy and paste the GitHub Repo URL under the GitHub Project Section.

  2. Choose the option GitHUb Hook trigger, So that webhook will apply the changes made to the GitHub repo automatically.

  3. Go to GitHub repo Settings >> Webhooks >> Add Webhook, Now add the webhook in the below-given format: http://<jenkins_public_ip:8080>/GitHub-webhook/

  4. Now Set the Credentials, Go to Dashboard >> manage Jenkins>> credentials >> add Credentials.

Here select the type of credential, and enter the username, password, and description.

  1. Under the pipeline section, enter the pipeline script as shown below.

    This script includes various stages - code cloning, build, pushing the built image to the docker hub repo, and deployment.

The above code will clone the code, build the image, and push the image to the docker-hub repo.

Now build the job / Any small changes made to the GitHub repo will build the job automatically.

To view the webpage, take the jenkine_public_ip:8080. Below given is the webpage of the deployed my-django-app.

So I encourage you to try this on your own and let me know in the comment section about your learning experience

Thank you for reading! Your support means the world to me. Let's keep learning, growing, and making a positive impact in the tech world together.

Happy Learning ๐Ÿ˜Š๐Ÿ™Œ

Thank You! Stay Connected โ˜๏ธ๐Ÿ‘ฉโ€๐Ÿ’ป๐ŸŒˆ

Contact me at :

LinkedIn: Akash Singh

linkedin.com/in/akash-singh-48689a176

E-mail:

Did you find this article valuable?

Support Akash-DevOps by becoming a sponsor. Any amount is appreciated!

ย