Open geekflyer opened 1 year ago
After thinking about it, it seems it's possible to override CIRRUS_WORKING_DIR
via CIRRUS_ENV
file:
task:
container:
image: alpine:latest
change_dir_script:
- mkdir -p foo
- cd foo
- echo "Hello, Bar!" >> bar.txt
- echo "CIRRUS_WORKING_DIR=$CIRRUS_WORKING_DIR/foo" >> $CIRRUS_ENV
print_script:
- cat bar.txt
The example above will override the working directory in change_dir_script
and every following instruction will respect it.
This behaviour was not intended when we added CIRRUS_ENV
but it works. I've added an integration test to make sure the behaviour from the example above won't break.
cool thanks - that seems to work! I wrote a small starlark utility function to make this less verbose if anyone comes by this:
def change_working_dir(path):
return script("change working directory to {}".format(path), 'echo "CIRRUS_WORKING_DIR=$CIRRUS_WORKING_DIR/{}" >> $CIRRUS_ENV'.format(path))
can be used like this:
task(
instructions = [
change_working_dir("my-sub-dir"),
script("run stuff in sub dir", "echo stuff"),
]
)
Description
I'm running some tasks in a monorepo where all the relevant code for the job is in the
ui
subdirectory. Is there a more elegant / more DRY way to change the working directory to a subdirectory of the repo than this?