woodpecker/docs/docs/20-usage/35-advanced-yaml-syntax.md
2022-09-17 09:00:40 +02:00

1.2 KiB

Advanced YAML syntax

Anchors & aliases

You can use YAML anchors & aliases as variables in your pipeline config.

To convert this:

pipeline:
  test:
    image: golang:1.18
    commands: go test ./...
  build:
    image: golang:1.18
    commands: build

Just add a new section called variables like this:

+variables:
+  - &golang_image 'golang:1.18'

 pipeline:
   test:
-    image: golang:1.18
+    image: *golang_image
     commands: go test ./...
   build:
-    image: golang:1.18
+    image: *golang_image
     commands: build