Day26 of #90DaysOfDevOps Challenge

Day26 of #90DaysOfDevOps Challenge

Jenkins Pipeline:

Jenkins Pipeline is a suite of plugins that supports implementing and integrating continuous delivery pipelines into Jenkins. This process involves building the software in a reliable and repeatable manner, as well as progressing the built software (called a "build") through multiple stages of testing and deployment.

The continuous delivery pipeline starts when a developer makes any changes and commits it to the source code, the pipeline then builds the artifact, tests the application, and releases it to deliver to the customer.

In Jenkins, we can write the pipeline as a code either in the UI or in a text file called Jenkinsfile which can be committed to the repository with the source code.

There are two ways of defining a pipeline in Jenkins -

  1. Scripted pipeline
  2. Declarative pipeline

In Declarative Pipeline syntax, the?pipeline?block defines all the work done throughout your entire Pipeline. agent?is Declarative Pipeline-specific syntax that instructs Jenkins to allocate an executor (on a node) and workspace for the entire Pipeline.

Jenkinsfile (Declarative Pipeline)
pipeline {
    agent any 
    stages {
        stage('Build') { 
            steps {
                // 
            }
        }
        stage('Test') { 
            steps {
                // 
            }
        }
        stage('Deploy') { 
            steps {
                // 
            }
        }
    }
}        

In a Scripted pipeline, one or more 'node' blocks do the core work throughout the entire pipeline, however, this block is not mandatory but having the block does 2 things -

  1. Schedules the steps contained within the block to run by adding an item to the Jenkins queue. As soon as an executor is free on a node, the steps will run.
  2. Creates a workspace (a directory specific to that particular Pipeline) where work can be done on files checked out from the source control.

Jenkinsfile (Scripted Pipeline)
node {  
    stage('Build') { 
        // 
    }
    stage('Test') { 
        // 
    }
    stage('Deploy') { 
        // 
    }
}        

Task:

  • Create a New Job, this time select Pipeline instead of Freestyle Project.

No alt text provided for this image

> Scripted Pipeline to print "Hello world".

No alt text provided for this image

> Output

No alt text provided for this image

  • Complete the example using the Declarative pipeline.

> Defined a Jenkinsfile in the repo.

No alt text provided for this image

> Configure the pipeline accordingly.

No alt text provided for this image

> Provide the path to Jenkinsfile.

No alt text provided for this image







> The pipeline builds successfully.

No alt text provided for this image

Thank you for reading ! ??


要查看或添加评论,请登录

Aishwarya keshri的更多文章

  • Day24 of #90DaysOfDevOps Challenge

    Day24 of #90DaysOfDevOps Challenge

    ??Project: Containerise and deploy a node.js application using Jenkins Job.

  • Day23 of #90DaysOfDevOps Challenge

    Day23 of #90DaysOfDevOps Challenge

    CI/CD Continuous integration and continuous delivery help in automating the software development lifecycle stages…

    2 条评论
  • Day22 of #90DaysOfDevOps Challenge

    Day22 of #90DaysOfDevOps Challenge

    ??Jenkins Jenkins is an open-source tool that helps in creating pipelines and automating the software development…

  • Day21 of #90DaysOfDevOps Challenge

    Day21 of #90DaysOfDevOps Challenge

    Important interview questions and Answers for Docker: 1. What is the difference between an Image, Container and Engine?…

  • Day20 of #90DaysOfDevOps Challenge

    Day20 of #90DaysOfDevOps Challenge

    Docker Cheat Sheet: ??Docker images- Show all locally stored top-level images: docker images Pull an image from a…

  • Day 19 of #90DaysOfDevOps Challenge

    Day 19 of #90DaysOfDevOps Challenge

    Docker Volumes When we are working on docker, the data we store gets lost when the container is destroyed. So, to…

    2 条评论
  • Day 18 of #90DaysOf DevOps Challenge

    Day 18 of #90DaysOf DevOps Challenge

    ?Docker Compose Using docker commands, we can only run and manage a single container at a time, but there can be…

  • Day17 of #90DaysOfDevOps Challenge

    Day17 of #90DaysOfDevOps Challenge

    Dockerfile: Instead of manually creating docker images by running multiple commands one by one, we can write a script…

    1 条评论
  • Day 16 of #90DaysOfDevOps Challenge

    Day 16 of #90DaysOfDevOps Challenge

    ?Docker: Docker is a containerization tool that helps us create a lightweight container with all the required packages…

  • Day15 of #90DaysOfDevOps Challenge

    Day15 of #90DaysOfDevOps Challenge

    ?Python Libraries: The collection of modules used in Python while writing different programs is known as libraries…

社区洞察

其他会员也浏览了