specify only directory and persist all files within, not the absolute to the file and it would not fail if the directory was empty or
You can do, below is a full example where persist_to_workspace is working on a directory, rather than a file. The only real complication is correctly setting the root point within the file system to allow this to happen. If you remove the “touch work/file” line this example should still work.
version: 2.1
orbs:
python: circleci/python@2.1.1
jobs:
test_persist_job:
docker:
- image: cimg/base:current
resource_class: small
steps:
- run:
name: create a working directory with a file for persist_to_workspace
command: |
mkdir work
touch work/file
pwd
ls
ls work
- persist_to_workspace:
root: ./
paths:
- "work"
test_attach_job:
docker:
- image: cimg/base:current
resource_class: small
steps:
- attach_workspace:
at: ./
- run:
name: display what was attached
command: |
pwd
ls
ls work
workflows:
test:
jobs:
- test_persist_job
- test_attach_job:
requires:
- test_persist_job
One thing to note is that any pattern matching is done using the rules defined by the Glob package found in the Go programming language