Setting Jenkins Declarative Pipeline through Jenkinsfile


Setting Jenkins Declarative Pipeline through Jenkinsfile

As we are aware Jenkins pipeline is set of the plugin which is used for implementation and integration of the CI/CD process.



What is Continuous Integration?

Continuous Integration (CI) is a development practice that requires developers to integrate code into a shared repository several times a day. Each check-in is then verified by an automated build, allowing teams to detect problems early.

What is Continuous Delivery?


Continuous delivery (CD) is a software engineering approach in which teams produce software in short cycles, ensuring that the software can be reliably released at any time and, when releasing the software, doing so manually. It aims at building, testing, and releasing software with greater speed and frequency.

So, In this Blog we are going to learn how to create a Jenkins declarative pipeline using Jenkinsfile.

In our previous blogs we already have seen how to Create Continuous Build and Delivery Pipeline in Jenkins.

Before Jumping into Jenkins Configuration we first need to create Jenkinsfile with the list of Dev-ops stages we want our build to pass through for e.g Build, Test, Deploy etc.

In this blog I am using the below Jenkinsfile you can create your own Jenkinsfile with the list of Dev-ops stage you wanted to configure. To Know more about Jenkinsfile please click it over here.

For demo purpose i have created one java program and for each commit, I will fetch all the code from the source control system such as GIT then build, test and deploy it.

To make sure that this pipeline will trigger for each build commit we can push this Jenkinsfile along with our project code in GIT or any other source code repository.


To Create Jenkins Pipeline using Jenkinsfile we need to follow the below process:

    1) From the Jenkins Home Page, Manage Jenkins-->Manage Plugin-->Install Pipeline declarative.


2)  Now Click on Create New item, Provide Jenkins Job Name, and Select Pipeline Project.


3) Now inside Pipeline Section, Select Definition as pipeline Script from SCM

4) SCM as GIT and provide the path of GIT Repository


5) Also, provide the Branch which we want to build under Branches to build.


6)  Under ScriptPath Provide the path of Jenkinsfile.


7)  Click on Apply and Save Job.


      Now we would be able to view all the Dev-ops stages getting executed which we have configured in Jenkinsfile.





SHARE THIS

Author:

My Name is Ankur Jain and I am currently working as Automation Test Architect.I am ISTQB Certified Test Manager,Certified UI Path RPA Developer as well as Certified Scrum Master with total 12 years of working experience with lot of big banking clients around the globe.I love to Design Automation Testing Frameworks with Selenium,Appium,Protractor,Cucumber,Rest-Assured, Katalon Studio and currently exploring lot in Dev-OPS as well. I am currently staying in Mumbai, Maharashtra. Please Connect with me through Contact Us page of this website.

Previous Post
Next Post
Anonymous
February 3, 2019 at 4:53 PM

Can you tell how we can restrict input string parameters to one. No comma separated multiple parameters but restrict input just to one parameter.

Reply
avatar
June 19, 2019 at 10:35 PM

Hi Ankur,
My name is Prasanjeet Singh. Currently, working at infosys with carrying 3.4 years of experience.
My question is:
If multiple developers are pushing the code on the same master branch in git what will it impact. How can we avoid the same. If this is possible then how?
Please reply to me
Thanks,
Prasanjeet Singh
victorsunny.85@gmail.com
8051017083,8296769356

Reply
avatar
June 23, 2019 at 4:28 PM

Hi Prasanjeet,
Usually No developer push there code directly to Master Branch as it is production copy.Below is the process that needs to be followed e
every developer/tester needs to create there own feature branch (local copy) and work on that.Once this activity is completed and code reviewed internally all can push the code to our GITHUB branch created for that particular release.Normally in this process lot of internal GIT Review and approvals are required.Once this local GITHUB branch is tested sucesfully this complete code can be push to Master.

Reply
avatar
January 20, 2020 at 4:52 PM

Hi Ankur,

Which is the best branching strategy in git.
Cloning the existing branch or creating a new branch from master locally.

Can u suggest any recommendations on the above.

Reply
avatar
May 19, 2020 at 10:07 AM

Hi Ankur, Do we have any pipeline script build and deployment for Front end applications written using ReactJS and backend applications using ruby ?

Reply
avatar