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:

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

kind: pipeline
type: docker
name: default

  image: &image golang:1.16

- name: build
  image: *image
  - go build

- name: test
  image: *image
  - 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

  - &my-anchor:
        - master

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

  - 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