You are currently viewing Jenkins Pipeline Tutorial using Groovy

Jenkins Pipeline Tutorial using Groovy


Jenkins Pipeline is a suite of plugins that supports implementing and integrating continuous delivery and continuous integration (CI/CD) pipelines. It allows you to define your build process using a Domain Specific Language (DSL) called Groovy. In this tutorial, we’ll cover the basics of Jenkins Pipeline using Groovy with practical examples.


  • Jenkins installed and running.
  • A basic understanding of Jenkins and its concepts.

Creating a Simple Jenkins Pipeline

Step 1: Create a New Pipeline Job

  1. Open Jenkins in your web browser.
  2. Click on “New Item” to create a new job.
  3. Enter a name for your job (e.g., “MyPipeline”) and select “Pipeline” as the job type.
  4. Click “OK” to create the job.

Step 2: Define Pipeline Script

In the job configuration, scroll down to the “Pipeline” section and select “Pipeline script” from the “Definition” dropdown. Now, you can enter your Groovy-based pipeline script directly.

Example 1: Hello World Pipeline

This simple pipeline defines one stage named “Hello” with a single step that echoes a message.

Step 3: Save and Build

Click “Save” to save the job configuration. Now, you can manually trigger the pipeline by clicking “Build Now” on the job page.

Advanced Jenkins Pipeline Concepts

Example 2: Multi-stage Pipeline with Parallel Execution

This pipeline has three stages: “Build,” “Test,” and “Deploy.” The “Deploy” stage is split into two parallel stages for deploying to staging and production environments.

Example 3: Using Parameters and Conditions

This pipeline introduces a parameter named ENVIRONMENT. The “Deploy” stage is conditional, and it will only run when the selected environment is “Staging.”


Jenkins Pipeline with Groovy provides a flexible and powerful way to define your CI/CD workflows. This tutorial covered the basics, but Jenkins Pipeline supports more advanced features, such as integrating with version control systems, using shared libraries, and handling error conditions. Explore the official Jenkins Pipeline documentation for more in-depth information and examples.

Leave a Reply