Jenkins Pipelines

Maciej
DevOps.dev
Published in
2 min readAug 4, 2022

--

Photo by Mike Benna on Unsplash

What is Jenkins ???

  • Congratulations! Your article is live on our publication. Do consider submitting more articles. Don’t forget to follow us on https://blog.devops.dev/ & on Twitter (https://twitter.com/devops_blog)An open source tool for continuous integration and continuous delivery.
  • It supports various platforms such as Windows, Linux, and Mac OS.
  • Define functions (Windows batch files, shell scripts, etc.) to be executed in units called jobs.
  • In my opinion, one of the features is that there are a lot of plug-ins for expanding functions.

What is Continuous Integration?

It is a method of shortening the release time by early detection of bugs, etc. by frequently performing a series of cycles of commit, build, test, and merge for the repository. Automate your builds and tests.

What is Continuous Delivery?

It is an extension of CI that shortens the release process by automating the entire release process. After successful build and test, deploy to test or staging environment and prepare to release to production environment.

What are Jenkins Pipelines ?

This is the type of job added from 2.0.Compared to conventional jobs, multiple steps (builds, tests, etc.) can be executed sequentially. Therefore, it can be used to realize a pipeline for continuous delivery. From the official documentation , there are two notations.

  • Declarative Pipeline
  • Scripted Pipeline

In the “Script” block of “Declarative Pipeline” and “Scripted Pipeline”, you can use the scripting language “Groovy”, which is also used in the build tool “Gradle”.

Declarative Pipeline

There are blocks that provide a variety of functions, such as “options”, which defines Pipeline execution options.

Example:

Explanation:

  • ##1 → Top block of Declarative Pipeline
  • ##2 → Agents defined in pipeline and stage blocks
  • ##3 → A block containing multiple stages such as Build, Test, Deploy
  • ##4 → Each stage block
  • ##5 → Stage step

Scripted Pipeline

Unlike the Declarative Pipeline, all blocks can use Groovy notation.

Example:

Explanation:

  • ##1 → Scripted Pipeline top block
  • ##2 → Stages such as Build, Test, and Deploy

Example Scripted Pipeline

Pipeline consists of three stages (Build, Test, Deploy), assuming that the plug-in Slack Notification has already been introduced, we will notify the build result to the slack channel. We can catch when an error occurs in each step.

In conclusion

When using Jenkins, I think Pipeline is useful in that in addition to being able to execute a series of steps in sequence, it is also possible to easily visualize the step that caused an error in the build in the “Stage View”.

--

--

DevOps Consultant. I’m strongly focused on automation, security, and reliability.