Breaking-Builds is a full CI/CD pipeline demo showcasing the journey of code from development to production, with each stage powered by Jenkins. The pipeline automates builds, tests, and deployments, ensuring that every line of code goes through the rigorous process of "cooking"—just like Heisenberg's meticulous lab work. This project demonstrates the power of automation in software delivery while having a fun Breaking Bad theme!
With this project, you can trigger builds, watch the stages unfold, and see firsthand how code is tested and deployed—without worrying about the DEA catching up with you.
- Automated Builds: The pipeline automatically builds code whenever a change is detected.
- Automated Testing: Unit tests are executed during the pipeline to ensure high-quality code.
- Deployment: Code is deployed automatically to production upon successful testing.
- Real-time Updates: Track the progress of each stage in the pipeline with live feedback.
- Integration with GitHub: GitHub integration ensures that every commit triggers the CI/CD pipeline.
- Jenkins: Orchestrates the entire CI/CD pipeline.
- GitHub: Hosts the code repository.
- Python: Used for backend code and tests.
- Render: Hosts the backend API.
- Docker: Used for containerized environments in Jenkins.
- React: Frontend for viewing build logs live and interacting with the pipeline interface.
- Github pages: Hosts the React frontend.
The Breaking-Builds pipeline follows a continuous integration and deployment process, orchestrated through Jenkins and triggered by both GitHub webhooks and the web app itself.
The backend, built with Flask, connects to Jenkins via its API, enabling actions such as triggering builds and retrieving build information. It serves as a bridge between the frontend and Jenkins, providing endpoints to initiate builds and fetch real-time updates on the build stages and logs.
The frontend, built with React, allows users to view the build logs and see the progress of each pipeline stage live. Users trigger builds manually through the web interface, simulating the pipeline for a more interactive experience. Each stage is displayed hierarchically, showing detailed logs as the build progresses.
The Jenkins pipeline, defined in a Jenkinsfile
, is configured to automate builds, testing, and deployments. It is triggered in two main ways:
-
Webhook Trigger: When new changes are pushed to GitHub, a webhook triggers the pipeline. For changes pushed to the
dev
branch, the pipeline merges tomain
after successful testing, which automatically redeploys the API (hosted on Render) in production. -
Manual Trigger via Web App: Users can trigger a build through the web app interface, which simulates the workflow, providing a mock deployment to allow users to experience the CI/CD process.
- Setup: Initializes the environment, setting the branch name for reference in later stages.
- Build: Installs necessary dependencies for the backend API.
- Test: Runs unit tests to validate code quality.
- Deploy - Mock: For non-dev branches, performs a mock deployment to simulate the CI/CD process.
- Deploy - Production: For the
dev
branch, merges changes tomain
to trigger deployment on Render.
The Jenkins setup for Breaking-Builds is configured to support Docker-based build agents and a custom pipeline. Below are key configuration details:
The Jenkins master is built from a Dockerfile
based on jenkins/jenkins:2.414.2-jdk11
, with additional tools and plugins installed.
To connect the master container to its Docker cloud host, an Alpine socat container is used, establishing a secure communication channel.
The pipeline relies on Docker agents configured with the label docker-python
. The agent image devopsjourney1/myjenkinsagents:python
is used, which is pre-configured with Python to support backend builds and testing. The Docker agent runs each stage in an isolated environment, ensuring dependencies are correctly installed and reducing potential conflicts.
Jenkins requires SSH credentials to authenticate with GitHub and deploy to production. A Jenkins credential, labeled JK
, is used for secure authentication during the production deployment stage. This enables Jenkins to merge changes from the dev
branch into main
and push updates automatically.
The Jenkinsfile defines the pipeline stages and logic. Specific configurations include:
- Branch Detection: The
BRANCH_NAME
environment variable is set based on the branch being built, which affects deployment behavior. - Build Triggers: Builds are triggered by GitHub webhooks for
dev
branch changes, leading to automatic deployment to main for production. - API Integration: Builds can also be triggered manually via the web app, simulating the CI/CD process.