0
0
JenkinsConceptBeginner · 3 min read

What is Step in Jenkins Pipeline: Definition and Examples

In Jenkins Pipeline, a step is a single task or command executed as part of the pipeline process. Steps are the building blocks that perform actions like running scripts, checking out code, or sending notifications within a stage.
⚙️

How It Works

Think of a Jenkins Pipeline as a recipe for building and delivering software. Each step is like an instruction in that recipe, telling Jenkins exactly what to do next. For example, one step might be to fetch the latest code from a repository, while another step might compile the code.

Steps run in order inside stages, which group related tasks together. This is similar to how a cooking recipe groups steps into preparation, cooking, and plating. Each step completes before the next one starts, ensuring the pipeline flows smoothly.

💻

Example

This example shows a simple Jenkins Pipeline with steps that print messages and run shell commands.

groovy
pipeline {
    agent any
    stages {
        stage('Example') {
            steps {
                echo 'Starting the build process'
                sh 'echo Running a shell command'
                echo 'Build process finished'
            }
        }
    }
}
Output
[Pipeline] echo Starting the build process [Pipeline] sh + echo Running a shell command Running a shell command [Pipeline] echo Build process finished [Pipeline] End of Pipeline
🎯

When to Use

Use steps whenever you want Jenkins to perform a specific action in your pipeline. This includes tasks like compiling code, running tests, deploying applications, or sending notifications.

For example, in a real project, you might use steps to:

  • Check out source code from Git
  • Run unit tests with a testing tool
  • Build a Docker image
  • Deploy the application to a server
  • Notify the team via email or chat

Steps make your pipeline flexible and powerful by letting you automate every part of your software delivery process.

Key Points

  • A step is a single action inside a Jenkins Pipeline.
  • Steps run inside stages to organize the pipeline.
  • Common steps include echo, sh, checkout, and more.
  • Steps execute sequentially to automate build, test, and deploy tasks.

Key Takeaways

A step is a basic task executed in a Jenkins Pipeline to perform actions.
Steps run inside stages and execute in order to automate workflows.
Use steps to run commands, scripts, or Jenkins-specific functions.
Steps help break down complex pipelines into manageable tasks.