You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/07/14 17:16:00 UTC

[GitHub] [airflow] leomarques90 commented on issue #13445: BashOperator "env" should extend os envvars and not entirely replacing them

leomarques90 commented on issue #13445:
URL: https://github.com/apache/airflow/issues/13445#issuecomment-1184698309

   > Copying all the environmental ones doesn't sound good to me. There are cases when Airflow has certain environmental variables, and the script should not have these variables, especially since environment variables very often contain secrets.
   > 
   > You can easily add this behavior in your DAG code so I don't see any reason to make suggested change.
   > 
   > ```shell
   >     task = BashOperator(
   >         task_id='runme',
   >         bash_command='./my-script.sh ',
   >         dag=dag,
   >         env={
   >             'CUSTOM_ENV': 'CUSTOM_VALUE',
   >             **os.environ
   >         }
   >     )
   > ```
   
   For those who are considering adding "**os.environ", and have sensitive data on environment variable, another way to not override the environment variables and avoid showing it on "Task Instance Details -> env" dag option, it to set the parameter `append_env` to `True`, like:
   ```shell
       task = BashOperator(
           task_id='runme',
           bash_command='./my-script.sh ',
           dag=dag,
           env={
               'CUSTOM_ENV': 'CUSTOM_VALUE',
           },
           append_env=true
       )
   ```
    


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org