Day 10: Jenkins Declarative CI/CD Pipeline Project

On AWS

Β·

3 min read

Day 10: Jenkins Declarative CI/CD Pipeline Project

Project 1: Notes App

Prerequisites βœ…

  1. EC2 instance πŸ–₯️

  2. GitHub πŸ™

  3. Docker 🐳

  4. Docker Hub 🏠

  5. Jenkins πŸš€

Steps Included:

πŸ› οΈ Configuration Steps:

  1. Create EC2 Instance:

    • Set up a new EC2 instance on AWS.πŸ–₯️
  2. SSH Connection:

    • Connect to your EC2 instance using SSH.πŸ”—
  3. Update Instance:

    • Ensure your instance is up to date with the latest updates.πŸ”„
  4. Docker Installation:

    • Install Docker on your EC2 instance.🐳
  5. User Addition to Docker Group:

    • Add your user to the Docker group for seamless Docker access.πŸ‘₯
  6. Java Installation:

    • Install Java on your EC2 instance.β˜•
  7. Jenkins Installation:

    • Install Jenkins on your EC2 instance.πŸš€
  8. Jenkins User to Docker Group:

    • Grant Jenkins user access to the Docker group.πŸ‘©β€πŸ’»πŸ³
  9. Reboot Instance:

    • Reboot your EC2 instance for changes to take effect.♻️
  10. Inbound Rules Configuration:

    • Edit inbound rules to allow access to Jenkins on port 8080.πŸšͺ
  11. Jenkins Setup:

    • Finally, configure and set up Jenkins for your continuous integration needs.πŸ› οΈ

πŸš€Pipeline Creation Steps:

  1. New Pipeline Setup:

    • Initiate the creation of a new pipeline.
  2. GitHub Project Selection:

    • Opt for the 'GitHub Project' option and input the GitHub URL for your project.πŸ™
  3. Pipeline Script Configuration:

    • Choose 'Pipeline Script' as the script option.πŸ“œ
  4. Groovy Scripting:

    • Use Groovy script to:

      • Clone the code from the specified GitHub repository.

      • Build a Docker image from the cloned code.

  5. Docker Hub Account Creation:

    • Create an account on Docker Hub.🏠
  6. Credentials Setup:

    • In Jenkins, navigate to 'Manage Jenkins' -> 'Credentials' -> 'System' -> 'Global Credentials' -> 'Add'.

    • Add Docker Hub credentials using environment variables.πŸ”

  7. Dockerhub Credentials in Code:

    • Use the 'withCredentials' Groovy syntax to provide Docker Hub login credentials within the pipeline code.πŸ”‘
  8. Image Retagging:

    • Retag the previously built image using the 'docker tag' command.🏷️
  9. Dockerhub Login:

    • Incorporate the script to log in to Docker Hub using the specified credentials.πŸ”’
  10. Image Push to Dockerhub:

    • Push the latest image to Docker Hub using the 'docker push' command.🚒

These steps collectively configure a comprehensive pipeline, from code cloning to Docker image pushing, including Docker Hub integration. 🌐🐳

🚒 Docker-Compose Deployment and Automated Build Configuration:

  1. Docker-Compose Integration:

    • Enhance pipeline robustness by deploying through Docker-Compose. Install Docker-Compose on the instance.🐳
  2. Security Configuration:

    • Edit inbound rules in security, adding port 8000 for improved access. Verify the application in the browser.πŸšͺ
  3. GitHub Repository Integration:

    • Optimize code retrieval by adding a Jenkinsfile to the GitHub repository, containing pipeline code.πŸ“
  4. Pipeline Configuration:

    • Choose the 'Pipeline from SCM' option in Jenkins.

    • Provide the GitHub repository URL, specify the branch, and mention the Jenkinsfile path. Save the configuration.πŸ”—

  5. Automated Declarative Checkout:

    • Trigger builds with Declarative Checkout SCM by simply clicking 'Build.' The Jenkinsfile in the repository automates the process of code retrieval.πŸ€–
  6. Webhook Setup in GitHub:

    • In GitHub repository settings, add a webhook for automation.

    • In Jenkins, go to 'Configure' -> 'Build Triggers' -> select 'GitHub hook trigger for GitSCM polling' -> Save.πŸ› οΈ

  7. Automated Build Trigger:

    • Any changes committed to the GitHub code trigger automatic builds in Jenkins, creating an efficient and automated build pipeline.πŸ”„

These steps optimize the deployment process through Docker-Compose, enhance security, and automate the build process with GitHub integration, ensuring a seamless and efficient pipeline. πŸš€πŸ”—

"πŸ™Œ Thank you for taking the time to explore this blog!πŸ“š I hope you found the information both helpful and insightful.✨

πŸš€ Enjoy your learning journey, and don't hesitate to reach out if you have any feedback. πŸ€“ Happy exploring!"

Β