Schema issues when trying to use persist_to_workspace

I’m getting Schema errors for this:

version: 2.1

jobs:
  build:
    machine: true
    steps:
      - checkout
      - run: docker build -t python-stream-grabber grabber
      - run: docker build -t python-stream-server server
      - persist_to_workspace:
        root: ./
        paths:
          - ./

What am I doing wrong in the persist_to_workspace?

# 1. [#/jobs/build] 0 subschemas matched instead of one
# |   1. [#/jobs/build] only 1 subschema matches out of 2
# |   |   1. [#/jobs/build/steps/3] 0 subschemas matched instead of one
# |   |   |   1. [#/jobs/build/steps/3] expected type: String, found: Mapping
# |   |   |   |   Shorthand commands, like `checkout`
# |   |   |   |   SCHEMA:
# |   |   |   |     type: string
# |   |   |   |   INPUT:
# |   |   |   |     persist_to_workspace: null
# |   |   |   |     root: ./
# |   |   |   |     paths: ./
# |   |   |   2. [#/jobs/build/steps/3] maximum size: [1], found: [2]
# |   |   |   |   long form commands like `run:`
# |   |   |   |   SCHEMA:
# |   |   |   |     maxProperties: 1
# |   |   |   |   INPUT:    
# |   |   |   |     persist_to_workspace: null
# |   |   |   |     root: ./
# |   |   |   |     paths: ./

persist_to_workspace should be a key which maps to its arguments, e.g.

- persist_to_workspace:
    root: ./
    paths:
      - ./

-Gordon

Isn’t that what I wrote in the config?

No, your config has a single list item with several keys, in JSON it would look like:

{"persist_to_workspace": null,
 "root": "./",
 "paths": ["./"]}

It needs to look like:

{"persist_to_workspace": {"root": "./",
                          "paths": ["./"]}}

which is what you get from the extra level of YAML indentation

Hope this helps

-Gordon

Wow I feel stupid… Thanks Gordon.

YAML doesn’t make this easy

docker:
- image: foo
- blork: bar

makes a map with a key pointing to a list, but

docker:
image: foo
blork: bar

makes a single map with three keys, with the docker key pointing to null.

It’s not at all intuitive :-/

Anyway, glad you’re unblocked

-Gordon

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.