我们如何使用气流 dag 执行 git push ?

时间:2021-06-16 08:14:32

标签: git airflow

我们如何使用气流 dag 执行 git push? 我正在尝试通过气流 dag 为特定分支执行 git push。

1 个答案:

答案 0 :(得分:0)

您可以使用 BashOperator 执行任何 bash 命令(包括 git)。

除了我已经包含的链接之外,您还可以执行以下操作:

git_push_task = BashOperator(
    task_id='git_push_example',
    # "scripts" folder is under "/usr/local/airflow/dags"
    bash_command="scripts/git_push.sh",
    dag=dag
)

scripts/git_push.sh 里面是这样的:

cd folder/you/want/
git push

记得给它执行权限:

chmod +x scripts/git_push.sh

您还可以查看 this post 中非常有用的信息。

相关问题