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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to