Pat
Esteemed Contributor

I know it's a bit old, but if someone is looking into a solution, then I was able to resolve the issue where I need to deploy some jobs only into the DEV target:

https://github.com/databricks/bundle-examples/tree/main/knowledge_base/target_includes.

Use YAML anchors to define resources once and include them only in specific targets.

File:resources/test_jobs.yml

# Define anchor with job configuration
job-config: &job-config
  my_test_job:
    name: "Test Job"
    tasks:
      - task_key: test_task
        notebook_task:
          notebook_path: tests/my_test.py

# Reference anchor only in dev target
targets:
  dev:
    resources:
      jobs:
        <<: *job-config  # Merge anchor here
  uat:
    # Empty - no test jobs in uat
  prd:
    # Empty - no test jobs in prd

File: databricks.yml

bundle:
  name: my_bundle

include:
  - ./resources/test_*.yml  # Include test jobs file

targets:
  dev:
    # test_jobs.yml adds resources here
  uat:
    # No test jobs
  prd:
    # No test jobs

Result:

  • dev target gets my_test_job
  • uat and prd targets have no test jobs