Skip to main content

Command Palette

Search for a command to run...

Day 27 - Jenkins Declarative Pipeline Project

Published
โ€ข3 min read
Day 27 - Jenkins Declarative Pipeline Project
A

๐Ÿš€ Welcome to the world of DevOps with Aakash! ๐ŸŒ

Hey tech enthusiasts! ๐Ÿ‘‹ I'm Aakash, a dedicated freelance Linux System Admin @xFusionCorp, and I'm on a mission to conquer the world of DevOps. Currently, I'm immersed in building exciting projects and sharing my learning experiences with you all.

๐Ÿ› ๏ธ My Tech Arsenal:

  • Docker
  • Linux
  • Kubernetes
  • Jenkins
  • AWS
  • Python
  • Java
  • Prometheus
  • Grafana
  • Ansible
  • Terraform

Join me in navigating the intricate realms of AWS DevOps technology. Let's embrace learning with gratitude and thrive in this ever-evolving landscape!

๐Ÿค Connect with me for:

  • Friendly chats
  • Shared experiences
  • Learning moments

Follow my journey on Twitter and Linkedin for daily insights and tech goodness. Let's build, automate, and innovate our way through the exciting world of DevOps! ๐Ÿš€ #DevOps #AWS #TechEnthusiast #InnovationJourney #90DaysOfDevOps

Introduction

Welcome DevOps enthusiasts. In this blog we will be revisiting the project "Todo-app" once again and create a Pipeline, but this time using Declarative Pipeline. This will be a short one, so without any further ado, let's begin building.

Task-01

  • Create a docker-integrated Jenkins declarative pipeline

  • Use the above-given syntax using sh inside the stage block

  • You will face errors in case of running a job twice, as the docker container will be already created, so for that do task 2

Task-02

  • Create a docker-integrated Jenkins declarative pipeline using the docker groovy syntax inside the stage block.

  • You won't face errors, you can Follow this documentation

  • Complete your previous projects using this Declarative pipeline approach

Solution Blueprint

Task 1

Creating a docker-integrated declarative pipeline with shell commands

pipeline {
    agent any

    stages {
        stage('Build') {
            steps {
                sh 'docker pull todo-app:latest'
            }
        }
        stage('Test') {
            steps {
                sh 'docker run todo-app:latest echo "Hello, Docker!"'
            }
        }
        stage('Deploy') {
            steps {
                sh 'docker run todo-app:latest echo "Deploying..."'
            }
        }
    }
}

Task 2

Creating a docker-integrated declarative pipeline with Groovy Script

pipeline {
    agent any

    stages {
        stage('Build') {
            steps {
                script {
                    docker.image('todo-app:latest').pull()
                }
            }
        }
        stage('Test') {
            steps {
                script {
                    docker.image('todo-app:latest').run('echo', 'Hello, Docker!')
                }
            }
        }
        stage('Deploy') {
            steps {
                script {
                    docker.image('toso-app:latest').run('echo', 'Deploying...')
                }
            }
        }
    }
}

Here's the Blueprint of solution of Project mentioned in Blog 24. Recreate the Project and share it on LinkedIn.

NOTE: A detailed blog about the project will come soon.

Conclusion

In this weblog, we revisited our Todo-app project and confirmed how to create Jenkins declarative pipelines with Docker integration the usage of two extraordinary procedures.

For Task 01, we utilized the sh syntax within the level blocks to interact with Docker. This approach is easy but may come upon errors whilst jogging the task multiple instances because of present Docker packing containers.

For Task 02, we hired the Docker Groovy syntax in the stage blocks. This technique presents more manage and versatility, ensuring smooth execution without errors even when going for walks the task more than one times.

By embracing the declarative pipeline method, we've streamlined our CI/CD process, making it more effecient and maintainable. With Docker integration, we make certain consistency throughout distinct environments, permitting seamless testing and deployment of our Todo-app.

Stay tuned for an in depth blog about this undertaking, where we're going to dive deeper into its architecture, implementation information, and fine practices. Don't forget to proportion your thoughts and studies with us on LinkedIn.

I hope this blog added some value to your learning. Ending this with a quote

Be like a postage stamp. Stick to one thing until you get there. - Josh Billings

Happy Learning

90DaysOfDevOps

Part 14 of 39

In this series I will be positing my learnings of DevOps for 90 days continuously. We will be starting from the basics covering linux and will go upto covering the advanced concepts of DevSecOps.

Up next

Day 26 - Jenkins Declarative Pipeline

Introduction We have learned in the previous blogs about creating pipeline through Jobs, but Jenkins recently introduced another way of creating a pipeline, pipeline as code, known as the Declarative pipeline. Welcome DevOps enthusiasts, In this blog...

More from this blog

D

DevOps with Aakash: Unleashing DevOps Excellence

44 posts

I'm Aakash, a freelance Linux System Admin @xFusionCorp, diving deep into the world of Docker, Kubernetes, Jenkins, AWS, and more. Let's navigate AWS DevOps tech together! Connect with me for friendly chats, shared experiences, and learning moments. Follow my journey on Twitter and Linkedin for daily insights. Let's build, automate, and innovate in the exciting world of DevOps! ๐ŸŒ