Skip to main content
In this guide, you’ll learn how to set up a basic Jenkins Pipeline that prints “Hello World” and then extends to run Maven commands. We’ll cover:
  • Creating a Pipeline project
  • Configuring the pipeline script
  • Running a Hello World job
  • Viewing build output and timing
  • Adding automatic Maven installation
Whether you’re new to Jenkins or looking for a refresher, this step-by-step tutorial will get you up and running quickly.

1. Create a Pipeline Project

  1. In the Jenkins UI, click New Item.
  2. Enter hello-world-pipeline as the name.
  3. Select Pipeline and click OK.
You now have a fresh Pipeline project ready to configure.
The image shows a Jenkins interface where a new item named "hello-world-pipeline" is being created, with the "Pipeline" option selected.

2. Configure the Pipeline

Open your new project’s configuration to see sections like General, Build Triggers, and Pipeline. You can:
  1. Under Pipeline, choose Pipeline script.
  2. (Optional) Enable Use Groovy Sandbox to restrict script permissions.
The image shows a configuration screen for a "hello-world-pipeline" in a web interface, where a pipeline script can be defined and edited. There are options to use a Groovy Sandbox and buttons to save or apply changes.
The image shows a Jenkins configuration screen for a pipeline project, with options for defining the pipeline script from SCM, selecting SCM type, and specifying the script path.

3. Hello World Pipeline

Paste this Declarative Pipeline into the script box:
  • agent any runs on any available node.
  • stage(‘Hello’) contains an echo 'Hello World' step.
Enabling the Groovy Sandbox is recommended if you’re running untrusted scripts. It prevents unauthorized method calls.
Click Apply, Save, then Build Now.

4. View the Results

After triggering the job, the dashboard shows build status, history, and links to console output.
The image shows a Jenkins dashboard for a pipeline named "hello-world-pipeline," displaying its status, build history, and permalinks for recent builds.
Click the build number or stage name to open the console log:
The image shows a Jenkins pipeline console with a successful build labeled "Build #1," displaying details of the "Hello" stage and a "Hello World" print message.
Raw console output:
Switch to Pipeline Steps or Timing to see per-step durations:
The image shows a Jenkins dashboard displaying the status of a build process, including details like build duration and timing. The interface includes options for viewing console output, editing build information, and pipeline overview.
The image shows a Jenkins interface displaying the steps of a pipeline execution, including stages and their execution times. The pipeline steps are listed with their respective arguments and status indicators.

5. Extending with Maven

Let’s enhance the pipeline to print the Maven version. Add a tools block:
If you run this now, you’ll get a compilation error because the tool name M3 isn’t defined in Jenkins yet.

6. Configure Maven in Jenkins

  1. Navigate to Manage Jenkins > Global Tool Configuration.
  2. Under Maven installations, click Add Maven.
  3. Name it M398, enable Install automatically, and choose version 3.9.8.
  4. Save your changes.
The image shows the "Manage Jenkins" dashboard interface, displaying various configuration and security options for managing Jenkins settings. It includes sections for system configuration, tools, plugins, and security settings.
The image shows a Jenkins configuration page for managing Maven installations, with options to install specific versions automatically.
Now update your Pipeline to use M398:

7. Build and Verify

Click Build Now again. You’ll see Tool Installation followed by Echo Version. Console snippet:

Conclusion

You’ve now:
  • Created a Jenkins Pipeline project
  • Written and executed a “Hello World” pipeline
  • Viewed build logs and timing
  • Configured Jenkins to install Maven automatically
Next steps: integrate SCM checkout, add test and deploy stages, and configure post-build notifications.

Watch Video