Continuous integration in dbt Cloud
To implement a continuous integration (CI) workflow in dbt Cloud, you can set up automation that tests code changes by running CI jobs before merging to production. dbt Cloud tracks the state of what’s running in your production environment so, when you run a CI job, only the modified data assets in your pull request (PR) and their downstream dependencies are built and tested in a staging schema. You can also view the status of the CI checks (tests) directly from within the PR; this information is posted to your Git provider as soon as a CI job completes. Additionally, you can enable settings in your Git provider that allow PRs only with successful CI checks to be approved for merging.
Using CI helps:
- Provide increased confidence and assurances that project changes will work as expected in production.
- Reduce the time it takes to push code changes to production, through build and test automation, leading to better business outcomes.
- Allow organizations to make code changes in a standardized and governed way that ensures code quality without sacrificing speed.
How CI works
When you set up CI jobs, dbt Cloud listens for a notification from your Git provider indicating that a new PR has been opened or updated with new commits. When dbt Cloud receives one of these notifications, it enqueues a new run of the CI job.
dbt Cloud builds and tests models, semantic models, metrics, and saved queries affected by the code change in a temporary schema, unique to the PR. This process ensures that the code builds without error and that it matches the expectations as defined by the project's dbt tests. The unique schema name follows the naming convention dbt_cloud_pr_<job_id>_<pr_id>
(for example, dbt_cloud_pr_1862_1704
) and can be found in the run details for the given run, as shown in the following image:
When the CI run completes, you can view the run status directly from within the pull request. dbt Cloud updates the pull request in GitHub, GitLab, or Azure DevOps with a status message indicating the results of the run. The status message states whether the models and tests ran successfully or not.
dbt Cloud deletes the temporary schema from your data warehouse when you close or merge the pull request. If your project has schema customization using the generate_schema_name macro, dbt Cloud might not drop the temporary schema from your data warehouse. For more information, refer to Troubleshooting.
Git providers who support CI
If your git provider has a native dbt Cloud integration, you can set up continuous integration (CI) job within dbt Cloud. For providers without native integration, you can still use a Git URL. The following table explains the available integration options and their capabilities.
Git provider | Native dbt Cloud integration | Automated CI job | Git import with URL | Information |
---|---|---|---|---|
Azure DevOps enterprise | ✅ | ✅ | ✅ | Organizations on the Team and Developer plans can connect to Azure DeveOps using a deploy key. Note, you won’t be able to configure automated CI jobs but you can still develop. |
GitHub developerteamenterprise | ✅ | ✅ | ✅ | |
GitLab developerteamenterprise | ✅ | ✅ | ✅ | |
All other git providers imported with a git URL (BitBucket, AWS CodeCommit, and others) | ❌ |