Steps are the smallest executable units within a Jenkins pipeline stage, representing individual actions like running shell commands, checking out code, or archiving artifacts
In Jenkins Pipeline, steps are the fundamental building blocks that define the actual work to be performed. Each step represents a single action, such as executing a shell command, cloning a Git repository, or archiving build artifacts. Steps are contained within the steps block of a stage, and a stage must contain at least one step. While stages provide logical organization and visualization, steps do the real work of building, testing, and deploying your application.
Shell/Batch Steps: Execute system commands using sh (Linux/macOS) or bat (Windows). Essential for running build tools, scripts, and command-line operations.
SCM Steps: Interact with version control using steps like git, checkout, or svn to retrieve source code.
File Operations: Steps for archiving artifacts (archiveArtifacts), copying files, or reading/writing files during the build.
Build Tool Steps: Specialized steps for Maven (maven), Gradle (gradle), or other build tools, though often just called via sh.
Notification Steps: Send notifications via email, Slack, or other channels using steps like emailext or slackSend.
Pipeline Utility Steps: Built-in steps like echo for logging, input for manual approvals, and timeout for execution limits.
Test Reporting Steps: Publish test results with steps like junit, publishHTML, or cobertura for code coverage.
Credentials Steps: Securely access credentials using withCredentials or withAWS steps to avoid exposing secrets in logs.
The key distinction in Jenkins Pipeline is that stages provide the logical structure and visualization, while steps perform the actual work . A stage represents a phase of your delivery process (like 'Build' or 'Test'), and within that stage, you define multiple steps that execute sequentially. For example, a 'Build' stage might contain steps to compile code, run linters, and generate documentation. Each step appears in the pipeline logs and contributes to the overall success or failure of the stage.
Steps run within the context of the agent specified for the pipeline or stage. They have access to environment variables defined in the environment block, workspace files, and any tools installed on the agent. Steps can also capture output, return status codes, and affect the flow of the pipeline. The declarative pipeline syntax requires that steps be contained within a steps block, and each step is executed in order. Jenkins provides a rich set of built-in steps, and plugins can add additional step types for specialized functionality .