# Pipelines

> A pipeline is what happens to each new revision of a version group, stage by stage: build, checks, deployments, releases and approvals.

**A pipeline is what happens to each new revision of a version group, stage by stage: it builds, deploys, releases into other groups, and checks before going on.**

One per: version group
Its stages: Build, then yours, such as Beta and Prod
A candidate: each revision a build of the group makes

## How a revision walks it {#how}

```text
Build  →  Beta: deploy, then check its health and wait an hour  →  Prod: approval, then deploy
```

1. **Build** is always the first stage: new commits are built into the group, and each revision that build makes is a **candidate**.
2. Each stage holds one candidate at a time. When it's free, it takes the newest candidate that passed the stage before; older ones are skipped.
3. A stage deploys or releases to all its targets at once, then runs its checks, in order. The first check that fails stops that candidate there.
4. A stage that deploys looks at each environment's [lock](environments.md#locks) first: while someone holds one, it waits without deploying, and a newer candidate takes its place.

## Stages {#stages}

A stage does one thing, and its checks:

| A stage that… | does |
|---|---|
| **deploys** | a deployment of the group's main package to each of its environments |
| **releases** | builds chosen packages into other version groups, which makes a candidate of their own pipelines |
| only **checks** | its checks, for a gate of its own |

A library's pipeline never deploys: its stages release, so a library reaches the groups that use it. A release stage skips what a group already has at that commit, and what it holds.

## Checks {#checks}

| Check | Passes when |
|---|---|
| **approval** | someone approves it in the Pipelines app |
| **wait** | the time is up: a bake time, from 1 minute to a week |
| **command** | a command, run on plinto's build servers, exits 0 |
| **webhook** | your URL answers, or calls back |

A check, an approval excepted, fails when an environment of its stage starts running another release meanwhile, deployed by hand or under a lock: it would be judging that release, not the candidate. **Retry** runs the stage again.

A check times out after 30 minutes unless it says otherwise, and after a day at most. A command gets the candidate in `PLINTO_CANDIDATE`, the check's name in `PLINTO_CHECK`, the packages in `PLINTO_PACKAGES` and its parameters as `PLINTO_PARAMETER_*`.

## What starts it {#triggers}

- **New commits**: the Build stage builds a branch's commits it hasn't tried.
- **A weekly merge**: on the night you choose, the group merges the group it tracks, which brings new releases of what it holds, never new packages.

## In the Pipelines app {#app}

**Build new commits**, **Release now** and **Merge now** start each by hand. Each stage shows what's **In it now**, and an approval waits for **Approve** or **Reject**. The editor adds stages with **Add a stage**, each one **Deploys** or **Releases**.

- [Deployments](deployments.md): what a deploying stage does
- [Builds](builds.md): the first stage
- [Environments](environments.md): where stages deploy
