This HandsOn will help you learn how to implement continuous integration and continuous deployment using declarative pipeline and deploy using Docker Container.
Create EC2 Instance and install the Jenkins & Docker on the Server.
for the Installation of the Jenkins And Docker Please follow the Official Document.
Step1 : On the Dashboard-> Select New Item -> enter the name of the project -> Select the Pipeline -> then ok
Step 2 - Write a description of the Project -> Click on the GitHub Project and the paste git repo link over there
Step 3 - Build Trigger -> Click on the GitHub Hook Trigger polling
GitHub Hook Trigger polling- Which is use for the , when we/anybody can changes the Done on the GitHub , Which will reflect on the pipeline it will trigger.
Step 4 - Create the Declarative Pipeline using Groovy Syntax
Using this Script we can run our pipeline-
Explanation of the script -
Here All the stages are the agents of the pipeline. so using these stages we can build our pipeline.
stage1 : Clone Code - these stage use for cloning the code of our repository,
stage2 : Build Image - These stage is use for Building the code for making the Docker Image. using these Docker Image we can Deploy these code on the docker Container and after deploying it will accusable on the browser.
Stage 3 : Push to Docker Hub - Using these stage , after Building the code , we can push the image on the docker hub , for pushing the image, we need to login on the docker , and tagging the image and push on the docker hub, for all of these task we use these stage. Also need to add credentials on the manage Jenkins -> global tool configuration using adding the credentials .
stage 4 : Deploy Container - These stage is use for the deploying the container , using the Docker image, which is we build in the previous stages.