Pipelines
Coming from GitLab CI
How each GitLab CI construct is written in a branchd pipeline file, with a worked conversion.
Available in repositories branchd reads pipeline files for. It is switching repositories on one at a time: until yours is, it keeps running its
.forge-ci.yamlor.xeonr-ci.yaml. See What is available.
Mapping
| GitLab CI | Pipeline file |
|---|---|
.gitlab-ci.yml | .branchd/pipelines/<name>.yaml, one file per pipeline |
stages:, stage: | None. Order jobs with needs:. |
workflow: rules: | on: |
rules:, only:, except: | One if: per job; changed() for rules: changes: |
when: manual | manual: true |
when: always (a job) | if: always() |
script: | steps:, each - run: … |
before_script: | The first steps |
after_script: | A last step with if: always() |
variables: | env: |
default: | defaults: (image, runs-on) |
image: | image: |
services: [{name, alias}] | services: {<alias>: {image, env}} |
tags: | runs-on: |
cache: {key: {files, prefix}} | cache: {files, key} |
artifacts: {expire_in} | artifacts: {expire-in} |
dependencies:, needs: {artifacts: false} | needs: [{job, artifacts: false}] |
parallel: matrix: | matrix: |
allow_failure: | continue-on-error: |
resource_group: | concurrency: (a lock name) |
interruptible: true | concurrency: {cancel-in-progress: true} |
environment: | environment: |
retry: | retry: |
timeout: | timeout: |
extends:, hidden jobs, !reference | A composite step, a reusable pipeline, or YAML anchors |
include: | uses: |
trigger: (multi-project) | trigger:, and the target declares on: trigger |
| Child pipelines | Several files, or a reusable pipeline |
$CI_* variables | Still set, apart from CI_JOB_STAGE |
rules: if: $CI_COMMIT_BRANCH == "main" | if: branch == 'main' |
rules: if: $CI_PIPELINE_SOURCE == "merge_request_event" | if: event == 'pull_request' |
| Pipeline schedules in settings | on: schedule in the file |
A worked conversion
Before:
# .gitlab-ci.yml
# Before: a GitLab CI file with stages, rules, a service, a cache and a
# manual deploy.
stages: [test, build, deploy]
variables:
GOFLAGS: -mod=readonly
default:
image: golang:1.26
test:
stage: test
services:
- name: mysql:8
alias: mysql
variables: {MYSQL_ROOT_PASSWORD: test}
cache:
key: {files: [go.sum], prefix: go-mod}
paths: [.cache/mod]
before_script:
- export GOMODCACHE="$CI_PROJECT_DIR/.cache/mod"
script:
- go test ./...
after_script:
- ./scripts/collect-logs.sh
build:
stage: build
rules:
- if: $CI_COMMIT_BRANCH == "main"
script:
- go build -o dist/server ./cmd/server
artifacts:
paths: [dist/]
expire_in: 1 week
deploy:
stage: deploy
rules:
- if: $CI_COMMIT_BRANCH == "main"
when: manual
resource_group: production
environment: {name: production, url: https://app.example.com}
script:
- ./scripts/deploy.sh production
After:
# .branchd/pipelines/ci.yaml
# After: the same pipeline. Stages become needs:, rules: become on: and
# if:, before_script and after_script become steps.
name: CI
on:
push:
branches: [main]
pull_request:
env:
GOFLAGS: -mod=readonly
defaults:
image: golang:1.26
jobs:
test:
services:
mysql:
image: mysql:8
env: {MYSQL_ROOT_PASSWORD: test}
cache:
key: go-mod
files: [go.sum]
paths: [.cache/mod]
steps:
- run: export GOMODCACHE="$PWD/.cache/mod"
- run: go test ./...
- if: always()
run: ./scripts/collect-logs.sh
build:
needs: [test]
if: branch == 'main' && event == 'push'
steps:
- run: go build -o dist/server ./cmd/server
artifacts:
paths: [dist]
expire-in: 1 week
deploy:
needs: [build]
if: branch == 'main' && event == 'push'
manual: true
concurrency: production
environment: {name: production, url: 'https://app.example.com'}
steps:
- run: ./scripts/deploy.sh production
What changed:
stageswent;buildneedstestanddeployneedsbuild.- The two
rules:became oneif:each, andon:says the pipeline runs on pushes tomainand on pull requests. default: imagebecamedefaults: image.- The service's alias became its key.
before_scriptbecame a first step. Steps share a shell, so itsexportreaches the next step.after_scriptbecame a step withif: always().when: manualbecamemanual: true, andresource_groupbecameconcurrency.$CI_PROJECT_DIRbecame$PWD: a step starts in the checkout.
branchd ci lint names any key you missed, with its replacement.