How can we check the output of BashOperator in Airflow?

Viewed 2587

I'm very new to Airflow, I wonder if I execute a bash operator, how can we get the console output of that Operator? I'm wondering does setting xcom_push = true solve the problem? I'd very glad of anyone can answer this :)

3 Answers

To add to @kaxil's answer (as I don't have enough reputation to comment on his answer):

If your bash_command returns multiple lines that you want to include in xcom then add this to return everything on one line:

bash_command="<COMMAND> | tr '\n' '||'",

For those using Airflow 2+, BashOperator now returns the entire output (source), not just the last line and does not require specifying do_xcom_push (new name in 2+ instead of xcom_push), as it is true by default.

Related