Missing Anchor Documentation

is there any documentation about anchors?
Searching for anchor at https://docs.drone.io/ I get no result

Even though I’m able to use it I was wondering if it is possible to set anchors for all pipelines to avoid repeating the same information over and over again.

We don’t explicitly document anchors since this is a generic Yaml feature as opposed to a Drone feature. Perhaps we should consider providing some examples or a primer, or even linking to external Yaml tutorials … However, in the meantime, any generic tutorial on anchors should be applicable to Drone.

You can also use the following generic yaml tool to test out anchors:
https://yaml-online-parser.appspot.com/

For example, you can enter the below yaml in the above link to see how anchors work:

kind: pipeline
type: docker
name: default

defs:
  image: &image golang:1.16

steps:
- name: build
  image: *image
  commands:
  - go build

- name: test
  image: *image
  commands:
  - go test

Thanks for the reply @bradrydzewski
That’s make sense.

What I was trying to achieve is use one anchor on more than one pipeline like so:

kind: pipeline
name: pipe-1

anchors:
  - &my-anchor:
    when:
      branch:
        - master

steps:
  - name: step-1
    << : *my-anchor
---
kind: pipeline
name: pipe-2

steps:
  - name: step-2
    << : *my-anchor

Is this possible in any way?

the yaml specification dictates the each document is completely independent from the rest, which mean anchors cannot be shared across documents.

1 Like