DEV Community

Judith Pivoteau
Judith Pivoteau

Posted on

7 1

Jenkins Pipeline, succinct presentation

To access to the pipeline possibilities, you need to create a project with the pipeline default type.

Pipeline code must start by Pipeline {}
Into this, we can define stages like this: stage('NameOfStage') {}
And into these stages, we can define multiple steps like this: steps {}
Commands go into the steps. Before the stages, you should add an agent to let know Jenkins where to run and other configurations like post (defines other operations to come after the steps or stages) and tools (define the tool and put it on the PATH).

This matches a declarative pipeline;

There is also scripted pipelines which starts by: node {}
Then, you can add stages to it but no steps. The code resides in the stages.

A descriptive pipeline will checkout source code management (git) by itself before running anything contrary to a scripted one.

In a descriptive pipeline, you can add a script {} into a steps to execute some code otherwise, you are forced to use pre-formatted commands like sh mvn --version, echo Hello World!, etc.

We must use the Groovy language to code into a scripted pipeline (or the script block). Different Java libraries and plugins may be added to Jenkins depending on needs.
For example, to use the Double class, it should be added. I didn't know so I tried to build the project using it and once the build failed, I looked up the console log and saw a link to add the class. The link leads to a form when you can add or delete libraries. You can find this form in "Manage Jenkins" => "In-process Script Approval".

Some Jenkins environment variables are also alvailable to use into the pipeline: env.BUILD_NUMBER for example.

Also, the code of the pipeline can be stored in a Jenkinsfile which will be commited to your project repository defining the continuous delivery process as part of the project.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay