Skip to main content
Version: 0.8.0

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.