- In this project, we will be playing with Github, Jenkins,Sonarqube and Nexus.
- We will create Jenkins, Sonarqube and Nexus from Docker Container.
- Since we will require docker inside Jenkins. But the official jenkins image do not include docker inside the image. So we will create our own new Jenkins image.
- The jenkins image used in this project can be pull from dockerhub. Visit the link.
- In this project, Git is used as VCS(Version Control System).
- Github is used to store Source Code.
- Jenkins is used for CI/CD(Continuous Integration/Continuous Deployment).
- We will be using Declarative pipeline for this job.
- This pipeline will contain multiple stages where task will be describe.
- Jenkins automatically fetched the Github Repo, so we do not need to include that in any stage.
- Multiple stages included in this job are:
-
Stage 1:
- Since this is maven based application, we will run the
mvn test
command.
- Since this is maven based application, we will run the
-
Stage 2:
- Skip the Unit Test.
-
Stage 3:
- Clean the prebuild package and
install
create a new package.
- Clean the prebuild package and
-
Stage 4:
- Create a Project in Sonarqube. Remember it requires a Sonarqube Credentials.
-
Stage 5:
- Get quality status report back from Sonarqube.
- For this, we must create jenkins webhook in sonarqube.
-
Stage 6:
- Upload the artifact to the Nexus Repository.
- It reqiures Nexus Credentials to upload the artifact.
-
Stage 7:
- It builds a docker image of the application with the Job_Name and Build_ID.
- Remember, Docker must be installed inside Jenkins.
-
Stage 8:
- It tagged the image with registry.
-
Stage 9:
- It pushes the image to the Nexus Private Registry.
- It reqires Nexus credentials for that.
-
Stage 10:
- It removes old image to clean the space from the jenkins container.
-
Stage 11:
- Deploy the application from the docker image.
-
- Sonarqube is used for Code Analysis.
- Nexus is used for private repository.
- If you want to recreate this tutorial, follow the documentation from Wiki page.