Day 27 - Elevate Your Jenkins Pipeline with Docker ๐Ÿณ๐Ÿš€

Day 27 - Elevate Your Jenkins Pipeline with Docker ๐Ÿณ๐Ÿš€

ยท

2 min read

๐Ÿš€ Exciting news! ๐ŸŒŸ Day 27 of the #90DaysOfDevOpsChallenge is here, and we're taking our Jenkins Declarative Pipeline to the next level by integrating Docker! ๐Ÿ’ก Get ready to enhance your CI/CD workflows with the power of Docker containers. Let's dive in together and level up our skills! ๐Ÿ’ช๐Ÿณ

Building with Docker Using Jenkins Pipelines, Step-by-Step

๐Ÿ› ๏ธ Task-01: Creating a Docker-Integrated Pipeline

  1. Setting Up Jenkins:

    • Ensure Jenkins is installed and running on your system. ๐Ÿ› ๏ธ

    • Make sure Docker is also installed and configured correctly. ๐Ÿ› ๏ธ

  2. Creating a New Pipeline Job:

    • Log in to your Jenkins dashboard. ๐Ÿ–ฅ๏ธ

    • Click on "New Item" to create a new project. โž•

    • Enter a name for your project and select "Pipeline" as the project type, then click "OK." โœ”

  3. Defining Stages in the Pipeline:

    • Inside the pipeline script block, define stages for different steps of your CI/CD process. ๐Ÿ› ๏ธ

    • In the stage('Build'), use the sh step to execute the Docker build command: ๐Ÿš€

    • Replace node-todo-cicd with your desired image name and tag. ๐Ÿท๏ธ

  1. Committing and Running the Pipeline:

    Here's your Jenkins pipeline script formatted in a clean and organized manner:

     pipeline {
         agent any
    
         stages {
             stage('Clone Code') {
                 steps {
                     git url: 'https://github.com/Nilkanth1010/node-todo-cicd.git', branch: 'main'
                 }
             }
    
             stage('Build') {
                 steps {
                     sh 'docker build . -t node-todo-cicd'
                 }
             }
    
             stage('Run') {
                 steps {
                     sh 'docker run -d -p 8000:8000 node-todo-cicd'
                 }
             }
         }
     }
    

๐Ÿ‘จโ€๐Ÿ’ป Bonus Tip: Apply this declarative pipeline approach to your previous projects for streamlined containerization.

๐ŸŽ‰ How's your #90DaysOfDevOps journey going? Share your thoughts and experiences after four weeks of immersive learning! Let's continue to grow together and conquer new horizons in the world of DevOps. Happy Learning! ๐Ÿš€๐Ÿ‹

Did you find this article valuable?

Support Nilkanth Mistry by becoming a sponsor. Any amount is appreciated!

ย