Skip to content

Jinja2 Template

This example shows how to use Apache Airflow® built-in Jinja templating within a YAML-based DAG definition using DAG-Factory

Example DAG

example_jinja2_template_dag:
  default_args:
    start_date: "2025-01-01"
  schedule: "@daily"
  description: "A DAG that uses Airflow's built-in Jinja templates"
  catchup: false
  tasks:
    - task_id: "print_run_id"
      operator: "airflow.operators.bash.BashOperator"
      bash_command: "echo 'run-id is {{ run_id }}'"

    - task_id: "print_task"
      operator: "airflow.operators.bash.BashOperator"
      bash_command: "echo 'The task is {{ task }}'"
      dependencies:
      - print_run_id