Access environment variable in jenkinsfile which is set in python

I have set the value of environment variable in python.


in jenkins file i want to access its value.

echo "${MY_VAR}"
if ("${MY_VAR}" != "0" )
{ email = sh (script:
"""#!/bin/bash -e


But it is showing null value.

environment variables are process specific and only visible within the process where it is set and its child processes. You can’t set an environment variable and refer to it in the parent process or other processes

You could try another approach like:
Write the value into file with your python code.
And read the file on your pipeline