We earn commission when you buy through affiliate links.
This does not influence our reviews or recommendations.Learn more.
A step-by-step guide to creating the Jenkins pipeline
Why Jenkins Pipeline?
Continuous Delivery (CD) is an essential part of DevOps Lifecycle.
It makes sure that the software/utility developers are creating is always production-ready.
This is where Jenkins Pipeline comes into the picture.
In DevOps, Continuous Integration and Continuous Delivery (CI/CD) is achieved through Jenkins Pipeline.
Using Jenkins Pipeline for CD helps to deliver the software with faster and frequent releases.
This helps to incorporate the feedback in every next release.
What is Jenkins Pipeline?
Jenkins Pipeline is a combination of jobs to deliver software continuously using Jenkins.
I assume you know what Jenkins is.
If not then check out thisUdemy course to master Jenkins.
JenkinsFile is a simple text file that is used to create a pipeline as code in Jenkins.
It contains code in Groovy Domain Specific Language (DSL), which is simple to write and human-readable.
Either you could run JenkinsFile separately, or you could launch the pipeline code from Jenkins Web UI also.
There are two ways you might create a pipeline using Jenkins.
Before we get into the demo, if you have not installed Jenkins, yo install it first.
check that you have Jenkins up and running on your system.
Lets create a declarative pipeline.
On the Jenkins dashboard, tap on New Item.
Then enter an item name, for example, First Pipeline and choose the Pipeline project.
Let me explain the above blocks.
The Groovy code above, I am using for the JenkinsFile.
Any available agent is getting assigned to the pipeline.
Then I am defining the Build stage and performing a simple echo step.
Then I defined the Test stage where the step asks whether you want to proceed or not.
Finally, there is a Prod stage with a simple echo step.
The above-explained pipeline has stages that have simple steps for you to understand how it works.
Once you learn how to create a Pipeline, you might add more complexity and create complex pipelines also.
when you land the code in the Pipeline tab, punch Apply and Save.
Finally, tap on Build Now to start building the Jenkins Pipeline you just created.
This is how the user interface will look like when the pipeline runs.
This is how the output will look like ending with a SUCCESS message.
The above Jenkins Pipeline has created a docker image of Nginx.
you’ve got the option to verify that by running the below command.
you could see the Nginx docker image is also listed.
Conclusion
I hope this gives you an idea ofJenkins pipelinebenefits and how you’re able to create one.
The above is a simple demonstration, and the best way to learn is by trying building complex pipelines.