Requirement to run a databricks job from another job based on custom conditions using DAB

adhi_databricks
Contributor

Hi everyone,

I'm using Databricks Asset Bundles to deploy a job that includes a run_job_task, which requires a job_id to trigger another job.

For different targets (dev, staging, prod), I need to pass different job_ids dynamically. To achieve this, I’ve defined the variable in the variables section and tried to override it per environment in the targets section.

However, when I run databricks bundle validate, I encounter the following error:

 
ERROR: Variable 'job_id' is incorrectly defined in target override

Here’s a simplified version of what I’m trying:

 
variables:
  job_id:
    description: Downstream job ID

targets:
  dev:
    variables:
      job_id: 1234

  staging:
    variables:
      job_id: 5678

  prod:
    variables:
      job_id: 91011

resources:
  jobs:
    main_job:
      name: trigger-${bundle.target}-downstream
      tasks:
        - task_key: trigger_downstream
          run_job_task:
            job_id: ${var.job_id}
            wait_for_completion: true

Is this the correct way to define and override variables for different targets in Asset Bundles? Or should this be handled differently (e.g., through variable-overrides.json or CLI)?

Appreciate any guidance!

Thanks in advance!