Implemented a robust DevOps lifecycle to automate the company's build, test, and deployment processes. This project utilizes a Jenkins Pipeline to orchestrate the workflow, which is triggered by changes in a GitHub repository. This solution ensures a streamlined and efficient development and release process, with separate workflows for development and production environments.
The CI/CD pipeline is designed to respond to commits on different Git branches, providing a clear distinction between development and production activities.
A Git workflow is implemented with two primary branches:
developbranch: For ongoing development and feature work. Commits to this branch trigger a build and test job.masterbranch: For stable, production-ready code. Commits to this branch trigger a full build, test, and production deployment.
The pipeline is composed of the following jobs, defined in a Jenkinsfile:
-
buildJob (Triggered by bothmasteranddevelopbranches):- This job is triggered automatically by a commit to either the
masterordevelopbranch on GitHub. - It pulls the latest code from the repository.
- The code is then containerized using a
Dockerfile, which builds a new image based on the provided base image. - The application code is placed in the
/var/www/htmldirectory inside the container.
- This job is triggered automatically by a commit to either the
-
testJob (Triggered by bothmasteranddevelopbranches):- After the
buildjob is successful, this job is executed. - It runs a series of automated tests to verify the functionality of the application.
- If the commit was on the
developbranch, the pipeline stops here after a successful test.
- After the
-
prodJob (Triggered only by themasterbranch):- This job is only executed if the
buildandtestjobs are successful and the commit was on themasterbranch. - It pushes the newly built and tested Docker image to a container registry.
- It then deploys the application to the production environment.
- This job is only executed if the
| Tool/Technology | Role in Project |
|---|---|
| Configuration Management Tool | Used to install necessary software on machines to prepare them for the pipeline (e.g., Jenkins, Docker). |
| Git | Version control system for managing the application's source code and enabling the branching strategy. |
| Jenkins | CI/CD automation server to orchestrate the entire pipeline with a Declarative Pipeline Script. |
| Docker | Containerization platform for packaging the application and its dependencies into a portable image. |
| GitHub | Repository hosting service to store the code and trigger Jenkins builds. |
- Setup Configuration Management: Ensure the necessary software (Jenkins, Docker, etc.) is installed on your machines using a configuration management tool.
- Jenkins Configuration:
- Set up a Jenkins server and install the necessary plugins (e.g., Git Plugin, Docker Pipeline Plugin).
- Create a new Declarative Pipeline job in Jenkins.
- Configure the pipeline to connect to your GitHub repository and trigger builds on commit.
- Use the provided
Jenkinsfileto define thebuild,test, andprodstages.
- Git Workflow: Adhere to the defined Git workflow, making commits to the
developbranch for testing and themasterbranch for production releases.