Search code examples
oozieairflow

AirFlow dag id access in sub-tasks


I have a DAG with three bash tasks which is scheduled to run every day.

I would like to access unique ID of dag instance(may be PID) in all bash scripts.

Is there any way to do this?

I am looking for similar functionality as Oozie where we can access WORKFLOW_ID in workflow xml or java code.

Can somebody point me to documentation of AirFlow on "How to use in-build and custom variables in AirFlow DAG"

Many Thanks Pari


Solution

  • Object's attributes can be accessed with dot notation in jinja2 (see https://airflow.apache.org/code.html#macros). In this case, it would simply be:

    {{ dag.dag_id }}