Stages

Introduction

A stage is a pivotal component in a pipeline that organizes the execution sequence of jobs within a pipeline. Each stage represents a distinct phase in the software delivery process, such as building, testing, or deploying an application. Stages allow for logical grouping and separation of jobs, thereby enabling parallel execution for faster build and deployment times. They also facilitate efficient management of complex pipelines by breaking down the workflow into manageable units, providing clarity and control over the entire deployment process.

You can define the required stages for the pipeline as key-value pairs using the stages key.

You can fetch the current status of a stage by using << status.{stage_name} >>.

Note:
  1. Multiple stages in a pipeline run sequentially by default, proceeding one after the other. You have the option to define conditions for stage execution, allowing for personalized control over when each stage is triggered. Refer to this section to learn about defining conditions in the pipeline.

  2. In a pipeline configuration, there must be at least one stage and no more than five stages. Additionally, each stage can accommodate a maximum of five jobs, which includes parallel jobs.

Properties of a Stage

You can define the stages in your pipeline with one or more combinations of the below listed attributes:

Key Value is Mandatory
name Provide the stage name as a string value. Yes
jobs An array of jobs Yes
runner The name of the runner upon which the jobs have to be executed No
image The name of the image which is used for job execution in the particular stage. No
when The conditional logic based on which the stage must be executed. You can use “and”, “or”, “not”, “not-equal”, or “equal” operators along with the base condition. No

YAML Code Snippet for Stage

Here’s an example code snippet for stages that can be defined in a pipeline:

    
copy
stages: - name: testStage1 runner: runner1 image: testImage1 jobs: - testJob1 when: - and: - equal: - << pipeline.event.branch >> - master - true - name: testStage2 jobs: - testJob1 - - testJob2 - testJob3

The above code illustrates the following workflow:

  • There are two stages defined in the pipeline - testStage1 and testStage2.
  • The stage testStage1 executes one job(testJob1)and the stage testStage2 executes three jobs(testJob1 and a parallel job).The parallel job includes the jobs testJob2 and testJob3,respectively.
  • The runner and image has been defined at the stage level and will be utilized by both the stages.
  • The when condition validates if the current branch points to master, and if that holds true, the testJob1 will be executed.

Last Updated 2025-05-30 16:54:59 +0530 +0530