target/manifest.json your dbt job produced, so Cube needs no access to your dbt
repository. These recipes cover the common setups.
Every recipe assumes the CLI is installed and authenticated through environment
variables, which is the usual setup in CI:
target/manifest.json: dbt parse, dbt compile, dbt run, or dbt build.
Multiple dbt projects
Give every dbt project its own output folder and name prefix, and pull each one as an uploaded manifest. Multiple dbt projects explains why both are needed. When each project has its own repository and pipeline, add a job like this to each one, changing onlyPROJECT:
Commit through your own pull requests
If your data model lives in your own Git repository, let your CI commit the cubes instead of Cube.cube dbt generate converts a manifest and writes the files into your
working copy; it creates no Cube branch and commits nothing.
generate never deletes files, so clear each project’s folder first. Its folder holds
only generated cubes, so a cube whose dbt model was deleted disappears too:
--out . is the project root, and
--output-path is relative to it. With a single dbt project, drop the loop and the
two flags; the cubes go to the deployment’s saved Output path. Clear only the files
directly in that folder, as a pull does, so any per-project subfolders survive:
find model/cubes/dbt -maxdepth 1 -type f -delete.
Gate pull requests on generated cubes
To fail a pull request whose committed cubes no longer match its dbt project, regenerate them in the checkout and fail if anything changed:generate --check
writes nothing, but it only compares the files the run generated, so it misses those.
Neither generate recipe sends a “dbt sync is ready for review” email, so both can run
on every pull request.
CLI-mode deployments
A deployment in CLI deploy mode takes its data model fromcube deploy rather than from Git. Regenerate the
cubes in your project directory, then deploy it:
cube deploy uploads the whole directory and removes remote files that aren’t in
it, so run it from a complete checkout of your data model, and keep the manifests
outside that directory. Switch the deployment to CLI deploy mode once with
cube deployments update DEPLOYMENT_ID -d '{"deployMode":"cli"}'.
Promote a sync once it compiles
When the dbt pipeline is already your review step, a sync can merge itself to production once its cubes compile:--output-path and --name-prefix flags, this works the same
for a deployment with a single dbt project.
To compile and query the generated cubes before merging, see dbt sync as a CI
test gate.