Petclinic is a Spring Boot application built using Maven. This is what the End Application would look like.
I have created a Continuous Integration and Continuous Delivery Pipeline using the tools
- Git - Source Code Management
- AWS - For Jenkins, Nexus, Sonarqube and Dockerhost Servers
- Jenkins - Continuous Integration Tool
- Maven - Build Tool
- Nexus - Artifact Repository
- Sonarqube - Code Analysis
- Docker - Containerization
This is flow of the Pipeline. Jenkins, Sonarqube and Nexus comprises the CI part, Deploying application on Dockerhost comprises the CD part.
Developers will make changes in the source code. New commits will trigger Jenkins Build Job and will trigger all the subsequent Jobs. The changes will be reflected in the application as soon as the Jenkins Jobs have completed Buiding.
CONTINUOUS INTEGRATION:
- Setup Jenkins, Nexus, Sonarqube on AWS EC2 using shell scripts.(Please find the userdata scripts in the userdata folder).
- Do further configuration of Jenkins, Nexus, and Sonarqube servers. Install necessary plugins in Jenkins. Create users in Nexus and Sonarqube. Create repositories in Nexus.
- Create Jobs in Jenkins.
- Build Job - This Job will pull the source code from GIT and build it using Maven. It will generate a jar file.
- Test Job - To do unit testing.
- Integration Test Job - To do the integration testings.
- Sonarqube-Code-Analysis - This job will perform the Code Analysis and publish Result on sonarqube server.
- Deploy artifact to Nexus - This job will publish the artifact on Nexus Server.
Each job will start only if the previous job was successful.
CONTINUOUS DELIVERY:
- Setup a Docker host on EC2 server.
- Write Dockerfile and docker-compose files in Docker host.
- Create Job in Jenkins to build image and run the docker-compose file. This will bring up the application stack.
NOTE: In its default configuration, Petclinic uses an in-memory database (H2) which gets populated at startup with data. To have persistent data, I have used MySql database. Refer the docker-compose and Dockerfile to setup your Frontend Application and Link it with MySql Database.
Build Pipeline View in Jenkins