Imports
Use the import
keyword to reference tasks defined in another bob.yaml
.
For example, if you have a directory structure like this:
main
โโโ bob.yaml
โโโ backend
โย ย โโโ bob.yaml
โโโ ui
โโโ landingpage
โโโ bob.yaml
You can import an bob.yaml
from another subdirectories like this.
# main/bob.yaml
import:
- backend
- ui/landingpage
build:
hello:
cmd: echo "Hello from main Bobfile!"
dependson:
- backend/hello
- ui/landingpage/hello
Those are the tasks defined in the given child Bobfiles.
# main/backend/bob.yaml
build:
hsello:
cmd: echo "Hello from backend Bobfile!"
# main/ui/landingpage/bob.yaml
build:
hello:
cmd: echo "Hello from ui/landingpage Bobfile!"
Running bob build hello
in the toplevel directory you get something like this:
$ bob build hello
Building nix dependencies...
Succeeded building nix dependencies
Running task hello with 2 dependencies
backend/hello running task...
backend/hello Hello from backend Bobfile!
backend/hello ...done
ui/landingpage/hello running task...
ui/landingpage/hello Hello from ui/landingpage Bobfile!
ui/landingpage/hello ...done
hello running task...
hello Hello from main Bobfile!
hello ...done
โ โ โ โ
Ran 3 tasks in 0s
backend/hello โ (0s)
ui/landingpage/hello โ (0s)
hello โ (0s)
Imports enable you to better organize projects and have modular build pipeline which maps your current project structure.
The import
statement is even more useful when working on multi-repository architectures. If you have to deal with that, head over to next section and learn about Workspaces.