Pipelines
A pipeline is a group of connected blocks. This page explains what pipelines are, how they organize workflow execution order, and what settings are available. In this page, the terms organization, server, and instance are used interchangeably.
Overview
Pipelines are groups of blocks that can be connected via dependencies to define their execution order.
Pipelines are also the unit of configuration. Each pipeline is encoded as separate a YAML file in the .semaphore
folder.
For reference, here is an example pipeline with its respective YAML.
- Example pipeline
- YAML
version: v1.0
name: Initial Pipeline
agent:
machine:
type: s1-kubernetes
os_image: ''
containers:
- name: main
image: 'registry.semaphoreci.com/ubuntu:22.04'
blocks:
- name: Build
task:
jobs:
- name: Build
commands:
- checkout
- echo "build commands here"
- name: Test
dependencies:
- Build
task:
jobs:
- name: Unit tests
commands:
- checkout
- echo "unit tests commands here"
- name: Integration tests
commands:
- checkout
- echo "integration tests commands here"
- name: UI Tests
dependencies:
- Test
task:
jobs:
- name: UI Test
commands:
- checkout
- echo "UI tests commands here"
Block execution order
In the same way that a block is a group of jobs, a pipeline is a group of blocks. Blocks can be connected using dependencies, which Semaphore uses to determine the execution order.
Take the following example:
- Blocks B and C depend on Block A
- Block D depends on both Blocks B and C
In this scenario, Block B and C wait until Block A is done. Block D in turn, waits for Blocks B and C to be finished.
You can reorder blocks by changing their dependencies using the visual editor.
Video Tutorial: How to reorder blocks
What if we removed all dependencies?
Pipeline initialization
Before Semaphore can start running the jobs in the pipeline, the pipeline YAML file needs to be retrieved from the repository. As a first step, Semaphore requests the file to the Git provider and inspects its contents.
There are two types of pipelines:
- Static: they don't require runtime evaluations and can be used as-is
- Dynamic: contain elements that must be evaluated at runtime
Dynamic pipelines contain at least one of these elements:
Dynamic pipelines are evaluated in the initialization job.
Initialization job
The initialization job only takes place for dynamic pipelines. It runs in a dedicated initialization agent and performs the following steps:
- Clones the repository using Git
- Parses and evaluates conditions in the input YAML file using Semaphore Pipeline Compiler (spc)
- Saves the job output log
The Semaphore Pipeline Compiler (spc) is an open-source component. You can find the code in the spc repository
How to change the agent for init jobs
To change the agent that runs the initialization, see init agent.