Another way to create builds …

I’ll first get a simple example from day to day life. What is a pipeline? Here is an image of a pipeline,

Pipeline

Here you can see sections in the pipeline. Think these each parts have different processes. This is the concept that I want to highlight. Like that this Jenkins build process, there can have few steps to go from development to production journey. When we get all these steps together, we call it a pipeline. Look at the following image,

There are five steps in the above pipeline.

Commit — Checkout code from GIT, SVN etc.. servers Build — Build the code using encryption algorithms(if any) or using build automation tools in this stage. Test — Use this stage to run tests such as Unit Tests, Integration Tests and other code quality tests. Stage — Browser testing can be done using tools like Selenium, Mocha etc. Deploy to QA or Development Testing — Code will be deployed to the staging server for testing. These are the steps of Development to Production according to this pipeline.

How to create a pipeline in Jenkins

Log into Jenkins, then click New Item in left panel. Enter a name for pipeline, consider not to give name with spaces in the middle. Using Camel case is better. Then select Pipeline from selections and click OK. [Figure1.0]

Figure1.0

Then you are redirected to the configuration screen of your created pipeline project. Then go to the pipeline section, select the definition as Pipeline script The important thing, give your Jenkins file name to Script Path. Select your SCM. [figure1.1]

figure1.1

Your Jenkins File should store under your project and give that path to this text box. Your Jenkins file will be like following which has written in groovy. For more: https://www.jenkins.io/doc/book/pipeline/jenkinsfile/

pipeline { agent any // indicates that Jenkins should allocate an executor and workspace for this part of the Pipeline

stages { //
    stage('Build') { // describes a stage of this Pipeline.
        steps { // describes the steps to be run in this stage
            sh 'make'
        }
    }
    stage('Test'){
        steps {
            sh 'make check' //executes the given shell command
            junit 'reports/**/*.xml' // use to make test reports
        }
    }
    stage('Deploy') {
        steps {
            sh 'make publish'
        }
    }
}

} junit is used to create rest reports when running the build such as phpunit and codeception(for PHP). Like this you can put your stages and steps according to your need when creating a build. After setting up the configurations correctly you click Apply and Save.

How is the process going on ?

First Jenkins get the clone or checkout whatever from given repository url and the going through the stages. In each stages it do what is about to do which has been given under stages of Jenkinsfile. So you can give your own steps through the process to make a build.

Advantages of A Pipeline

Developer should not worry about Jenkins knowledge. The knowledge about how to make a pipeline is enough. Whoever the person make builds just have to click and let it go.

Try to use Jenkins pipeline for your software build processes.

Thanks.