# Environmental variables limited to certain branches don't work during deployment

**URL:** <https://travis-ci.community/t/environmental-variables-limited-to-certain-branches-dont-work-during-deployment/13798>\
**Category:** Deployment\
**Tags:** bug\
**Created:** [May 4, 2023, 4:50pm UTC](https://travis-ci.community/t/environmental-variables-limited-to-certain-branches-dont-work-during-deployment/13798 "2023-05-04T16:50:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![khatchad](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/khatchad/32/8167_2.png) [@khatchad](https://travis-ci.community/u/khatchad)\
**Post date:** [May 4, 2023, 4:50pm UTC](https://travis-ci.community/t/environmental-variables-limited-to-certain-branches-dont-work-during-deployment/13798/1 "2023-05-04T16:50:24Z")

</div>

Referencing an environmental variable in the `script` part of a script deployment doesn’t work if I restrict the use of the environmental variables to particular branches (e.g., master). The problematic build is [here](https://app.travis-ci.com/github/ponder-lab/ML/jobs/601537093/).

If I remove the restricted environmental variables and create new ones with the same names but open to all branches, it works (see [this build](https://app.travis-ci.com/github/ponder-lab/ML/builds/262804018)).

## Regression

Note that using `after_script` to do the deployment using restricted environmental variables works (see [this build](https://app.travis-ci.com/github/ponder-lab/ML/jobs/601538038)).
