Introduction
Deploy inference rules allow you to register deployments in DX based on jobs that run in your CI/CD jobs. Inference rules are a no-code solution for simple deployment workflows, whereas the Deployments API is a more flexible solution that can handle a wide range of deployment mechanisms.
Setup
Deployment inference is configured by creating inference rules in the DX user interface. To set up a rule, specify the following parameters:
Pipeline Source: Select from Github Actions, GitLab, CircleCI, and other options based on connections you have configured in DX.
CI/CD Level:
GitHub Actions & CircleCI: Automatically set to "Workflow".
Buildkite: Automatically set to "Pipeline."
GitLab & Azure DevOps: Option to select either "Pipeline" or "Stage".
Repository: Select one from the dropdown, or input a regular expression.
Integration branch (optional): Set this value if you are using a branch to integrate changes before merging to a release branch.
Workflow: Select the specific workflow, pipeline, or stage for which you want a deployment to be generated from the dropdown. Regular expressions are
Target branch: The Git branch for which you want to infer deployments from, e.g.
main
,master
, ordevelopment
.Service: The name of service being deployed.
Understanding CI/CD Hierarchies
The second field for an inference rule is the CI/CD level. Following are the CI/CD hierarchies for each provider, with DX-imported levels in bold:
GitHub: Repository > Workflow > Job > Step
CircleCI: Project > Pipeline > Workflow > Job > Step
GitLab: Project > Pipeline > Stage > Job
Azure DevOps (ADO): Project > Repository > Pipeline > Stage > Job > Step
Buildkite: Pipeline > Step > Job
Examples
Inference rule examples:
When the GitHub workflow named "Deploy" runs on the "main" branch, infer a deployment to the "production" environment.
When the same workflow runs on the "staging" branch, infer a deployment to the "staging" environment.
Testing
After creating an inference rule, trigger the pipeline/workflow/stage to run on the relevant branch, then verify a deployment got added with the deployment_inference_rule_id
corresponding to the rule.
Backfilling
Once your rules are setup and verified, you may wish to have deployments backfilled based historical data. Please contact DX support to request that a one-time backfill be performed.
Regular Expressions
DX lets you use regular expressions to create rules for multiple repositories and/or workflows at once. Below are a few common examples:
To create a rule for all repos, use the expression
(.*)
To create a rule for all repos that begin with the term "mobile-", use the expression
(^mobile-.*)
To create a rule for all jobs that include the term "deploy", use the expression
(.*deploy.*)