Can I use persist_to_workspace on MacOS build?


#1

Hello!
Can I use persist_to_workspace on MacOS build?
I tried it, it does not seem to work.
I got an error:
Error parsing config file: yaml: line 13: found character that cannot start any token

It seems to work only on docker image. Is that correct?
Thank you!


#2

Please ignore. I got it working on MacOS build.


#3

Can you share how you got it working? It might be helpful to future readers.


#4

I had some tabs (or hidden characters) in the config.yml that was not obvious and I feel that error message was not pointing it out clearly. (or if I may say – error message was a bit misleading).
Here is a snippet of my config file that is working:

jobs:
  get_time_stamp:
    environment:
      WORKDIR: /Users/distiller/project/workdir
    macos:
      xcode: "9.2.0"
    steps:
      - run: date '+%Y-%m-%d' > todaysDate.txt
      - persist_to_workspace:
          root: .
          paths: todaysDate.txt

  macos_py2_miniconda:
    macos:
      xcode: "9.2.0"
    environment:
      WORKDIR: /Users/distiller/project/workdir
      PYTHON_VERSION: py2
    steps:
      - checkout
      - attach_workspace:
          at: .
      - run: *setup_miniconda
      - run: *prep_conda_cache
      - save_cache:
          key: macos_py2_conda_V101-{{ checksum "todaysDate.txt" }}
          paths: miniconda

In above code, I persist todaysDate.txt in the workspace, and I used it in many downstream jobs.


#5

Ah yes, it happens. Two ways to deal with that:

  • Use an YAML-parsing IDE with whitespace characters turned on (e.g. Netbeans)
  • Use an online YAML parser to see if your valid YAML produces a sensible data structure.

#6

Thank you!!