Get git commit messages in environment variable and access inside a function

I am trying to get all the commit messages by the following code in circle.yml

environment:
GIT_COMMIT_DESC: $(git log $CIRCLE_BRANCH ^origin/master --pretty=oneline)
How can I access GIT_COMMIT_DESC inside a method in a python file.
I am getting a KeyError: ‘GIT_COMMIT_DESC’ when I tried accessing it inside a method in python file
commitMessages = os.environ[‘GIT_COMMIT_DESC’]