As described above, the exit code has to be communicated through airflow via the script listed above. It should look something like this.
from airflow.operators.bash_operator import BashOperator
t2 = BashOperator(
bash_command='java -jar /home/ryada/airflow/talendjobs/AirflowAPIConnecter.jar; echo $?',
The actual logic is available in the execute function of the Bash Operator. As you can see, if the return value is
0 it will fail the conditional and won’t raise an AirflowException. Otherwise, any none zero return values will raise the exception causing the task to fail.
As for how you control the exit code as your program reaches various end states, the Java code below could be used to set the return value as described here.
Let me know if that resolves your query or if I need to elaborate the solution.