Skip to main content

Command Palette

Search for a command to run...

Day 24 Task: Complete Jenkins CI/CD Project

Published
2 min readView as Markdown

Setting Up Jenkins CI/CD for Django Todo App with Docker Compose

Introduction

In this tutorial, we'll explore how to create a robust Continuous Integration and Continuous Deployment (CI/CD) pipeline for a Django Todo App using Jenkins and Docker Compose. By the end of this guide, you'll have a fully automated workflow that builds, tests, and deploys your Django application whenever changes are pushed to your GitHub repository.

Prerequisites

  1. Basic understanding of Django and Docker.

  2. Jenkins installed and running.

  3. Docker and Docker Compose installed on your Jenkins server.

Task-01: GitHub Integration

Step 1: Fork the Repository

Start by forking the Django Todo App repository to your GitHub account.

Step 2: Create Jenkins Job

  1. Open Jenkins and create a new job.

  2. Choose "Freestyle project" or "GitHub Organization" based on your preference.

  3. Configure GitHub project URL and credentials.

  4. Enable GitHub Hook trigger for GITScm polling.

Step 3: GitHub WebHooks

  1. In your GitHub repository, go to "Settings" > "Webhooks" > "Add webhook."

  2. Set the Payload URL to your Jenkins webhook URL.

  3. Ensure the webhook is triggered for push events.

Task-02: Execute Shell and Docker Compose

Step 1: Docker Compose File

Create a docker-compose.yml file in your project root.

Step 2: Jenkins Execute Shell

Add a build step "Execute shell" in your Jenkins job configuration.

docker-compose up -d

Step 3: Post-build Actions

Add any post-build actions needed, such as archiving artifacts.

Step 4: Test Your CI/CD Pipeline

  1. Make a change in your GitHub repository and push it.

  2. Observe Jenkins triggering the build due to the webhook.

  3. Check the Jenkins console output for build logs and any issues.

Step 5: Treat Yourself

Once the pipeline is successfully set up, celebrate by running the Django Todo App and accessing it through your browser.

Conclusion

Congratulations! You've successfully created a Jenkins CI/CD pipeline for your Django Todo App. This automated workflow ensures that your application is built, tested, and deployed consistently, promoting a more efficient and error-free development process.

More from this blog

Introduction Of DevOps

108 posts