Problems with map merging and yaml anchors

I’m trying to DRY up several pipelines, and running into problems. Take this simple example:

bb_image: &image busybox

env: &env
  environment:
    - FOO=bar
    - BAR=QUIX

common: &common
  image: *image
  environment:
    - FOO=bar
    - BAR=QUIX
pipeline:
  one:
    image: *image
    <<: *env
    commands:
      - echo $FOO $BAR # these variables are empty

  two:
    <<: *common # error says "invalid or missing image"
    commands:
      - echo hello

This is valid YAML as far as I can tell (validated with http://yaml-online-parser.appspot.com/).

Why am I unable to merge in the map of environment variables in the first example?
Why does the second example return an error of invalid or missing image?
Are there other methods of reducing the amount of duplication in these configuration files, such that we don’t have to update all occurrences of image names and environment variables?

Thanks much!

The yaml parsing is handled by https://github.com/go-yaml/yaml which supports most, but not all, 1.1 features. I am not familiar enough with the internals of the library to answer specific questions, but it looks like you are trying to use features that the parsing library does not currently support.