# Read commit message as a CIRCLE environment variable

**URL:** <https://discuss.circleci.com/t/read-commit-message-as-a-circle-environment-variable/11699>\
**Category:** Build Environment\
**Tags:** python\
**Created:** [April 6, 2017, 6:17am UTC](https://discuss.circleci.com/t/read-commit-message-as-a-circle-environment-variable/11699 "2017-04-06T06:17:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vino](https://avatars.discourse-cdn.com/v4/letter/v/c2a13f/32.png) [@vino](https://discuss.circleci.com/u/vino)\
**Post date:** [April 6, 2017, 6:17am UTC](https://discuss.circleci.com/t/read-commit-message-as-a-circle-environment-variable/11699/1 "2017-04-06T06:17:47Z")

</div>

I have a project requirement to run certain test cases only on master builds. This is done by a unittest decorator like this `@unitttest.skipUnless(os.environ['CIRCLE_BRANCH'] == "master", "Run test cases only on master builds")`  
I also want this to run these test cases if a developer chooses to run it on any non-master branch.

I’m wondering if there is a way to override the unittest decorator with a git command(git commit/push) so that the test cases gets picked up and executed in Circle CI. Perhaps an environment variable which could read the PR label from github or the commit message ? Something like “[ci skip]” - But instead of skipping, which can be read as an environment variable within the CI environment ?

---

<div class="post-metadata">

**Author:** ![arindamnayak](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/arindamnayak/32/16049_2.png) [@arindamnayak](https://discuss.circleci.com/u/arindamnayak)\
**Post date:** [May 5, 2017, 11:16am UTC](https://discuss.circleci.com/t/read-commit-message-as-a-circle-environment-variable/11699/2 "2017-05-05T11:16:11Z")

</div>

Yes, you can use following command to read the commit message and set it as environment variable.

environment:  
GIT\_COMMIT\_DESC: git log --format=oneline -n 1 $CIRCLE\_SHA1

Note: $CIRCLE\_SHA1 is a predefined circleci environment variable.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [June 18, 2018, 11:39am UTC](https://discuss.circleci.com/t/read-commit-message-as-a-circle-environment-variable/11699/3 "2018-06-18T11:39:21Z")

</div>

Closed on June 18, 2018, 11:39am UTC


