Airflow XCom 在模板中发送变量
Airflow XCom send variables inside templating
我一直在尝试在 bash 脚本中将变量的内容发送到 Xcom。但是,我失败了。
test_bash = """
export test_val='123'
{{ ti.xcom_push(key='1',value=test_val) }}
echo $test_val
"""
bash_tash = BashOperator(
task_id='test',
bash_command=test_bash,
retries=3,
dag=dag)
在上面截取的代码中。当我试图拉它时。我无法向 Xcom 发送任何内容。我试过用单引号发送文本,效果很好。
有没有办法将变量从 bash 脚本发送到 xcom?
您可以使用 BashOperator 来推动您的价值:
test_bash = """
export test_val='123'
echo $test_val
"""
bash_task = BashOperator(
task_id='test',
bash_command=test_bash,
xcom_push=True
retries=3,
dag=dag)
然后你将价值拉入另一个任务。
我一直在尝试在 bash 脚本中将变量的内容发送到 Xcom。但是,我失败了。
test_bash = """
export test_val='123'
{{ ti.xcom_push(key='1',value=test_val) }}
echo $test_val
"""
bash_tash = BashOperator(
task_id='test',
bash_command=test_bash,
retries=3,
dag=dag)
在上面截取的代码中。当我试图拉它时。我无法向 Xcom 发送任何内容。我试过用单引号发送文本,效果很好。
有没有办法将变量从 bash 脚本发送到 xcom?
您可以使用 BashOperator 来推动您的价值:
test_bash = """
export test_val='123'
echo $test_val
"""
bash_task = BashOperator(
task_id='test',
bash_command=test_bash,
xcom_push=True
retries=3,
dag=dag)
然后你将价值拉入另一个任务。