Stages

To organize more complex pipelines composed of a significant number of steps, Microtica allows you to group multiple steps in stages, that suppose to execute in parallel.

#Stage syntax

Stages can be declared using stages property in the pipeline yaml by specifying the stage names in an ordered list. Declared stages can then be referenced from the steps by specifying the name of the stage.

All steps assigned to a certain stage are executed in parallel.

You can assign one stage to multiple steps but you can’t assign a step to multiple stages.

Steps that are not assigned to any stage will be automatically assigned to the default stage that will execute first.

Here is skeleton of pipeline with stages:

microtica.yaml

stages:
  - [first-stage-name]
  - [second-stage-name]

steps:
  step_1:
    stage: [first-stage-name]
    [step-body]
  step_2:
    stage: [second-stage-name]
    [step-body]

#Pipeline with multiple stages

In this example, we will create a pipeline that consists of two stages and three steps.

Here is the graphical preview of the pipeline:

Pipeline execution flow

In the example above, we define two stages, build and test. We also define three steps, BuildMyApp that belongs to the build stage, and TestMyApp and GenerateTestReports that belong to the test stage.

stages:
 - build
 - test

steps:
  BuildMyApp:
    stage: build
    image: node:latest
    commands:
      - npm install
      - npm run build
  TestMyApp:
    stage: test
    image: node:latest
    commands:
      - npm test
  GenerateTestReports:
    stage: test
    image: node:latest
    commands:
      - npm run generate-reports

The pipeline starts by executing the BuildMyApp step. When this step finishes with its execution successfully, TestMyApp and GenerateTestReports steps start execution in parallel.
Once the two steps within the test stage finish successfully, the pipeline execution is complete.