[
https://issues.apache.org/jira/browse/AIRFLOW-502?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16686194#comment-16686194
]
ASF GitHub Bot commented on AIRFLOW-502:
----------------------------------------
ron819 closed pull request #4075: [AIRFLOW-502] BashOperator success/failure
conditions not documented
URL: https://github.com/apache/incubator-airflow/pull/4075
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/airflow/operators/bash_operator.py
b/airflow/operators/bash_operator.py
index f9c2e1bbc0..1cdf8ed717 100644
--- a/airflow/operators/bash_operator.py
+++ b/airflow/operators/bash_operator.py
@@ -49,6 +49,16 @@ class BashOperator(BaseOperator):
:type env: dict
:param output_encoding: Output encoding of bash command
:type output_encoding: str
+
+ On execution of the operator the task will up for retry when exception is
raised.
+ However if a sub-command exists with non-zero value Airflow will not
recognize
+ it as failure unless the whole shell exits with a failure. The easiest way
of
+ achieving this is to prefix the command with ``set -e;``
+ Example:
+ bash_command = "python3 script.py '{{ next_execution_date }}'"
+ when executing command exit(1) the task will be marked as success.
+ bash_command = "set -e; python3 script.py '{{ next_execution_date }}'"
+ when executing command ``exit(1)`` the task will be marked as up for
retry.
"""
template_fields = ('bash_command', 'env')
template_ext = ('.sh', '.bash',)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> BashOperator success/failure conditions not documented
> ------------------------------------------------------
>
> Key: AIRFLOW-502
> URL: https://issues.apache.org/jira/browse/AIRFLOW-502
> Project: Apache Airflow
> Issue Type: Improvement
> Components: docs
> Reporter: Li Xuanji
> Assignee: Li Xuanji
> Priority: Major
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)