Using persist_to_workspace in Commands (key) in version 2.1 of circle.yml

I am using the Commands key in my circle.yml file and attempting to get persist_to_workspace working. How can I persist files between jobs when using Commands. I’ve played around with persist_to_workspace to no avail with either the “The specified paths did not match any files in /root/project” or “Error locating workspace root directory: stat /root/project/workspace: no such file or directory” errors.

Does persist_to_workspace work in Commands? Is working_directory necessary?

The simplified configuration is as follows:

version: 2.1

commands:
  prep:
    parameters:
      myvar:
        type: string
        default: myvalue
    steps:
      - run:
          name: Save something
          command: |
            echo -n << parameters.myvar >> > file1
  do-work:
    steps:
      - run:
          name: Run something
          command: |
            execute file1

jobs:
  prep-process:
    docker:
      - image: myimage:2.4.0
    steps:
      - Prep:
          myvar: 'some text'
  start-work:
    docker:
      - image: myimage:2.4.0
    steps:
      - do-work

workflows:
  version: 2
  build-and-deploy:
    jobs:
      - prep-process:
          context: staging
          filters:
            branches:
              only: staging
      - start-work:
          context: staging
          filters:
            branches:
              only: staging

Apologies for flagging this. Does anyone have suggestions about how I can persist files across jobs? My goal is to output database secrets generated on the fly to a service deployed using Kubernetes.

I’m facing the same issue.