Pipeline variables based on branch

Hi Gitlab forums.

I have two environments, staging and production. I would like to configure my master branch to deploy to production and my feature branch to deploy to staging.

The deploy process for both environments is identical. I would like the two jobs specified in my .gitlab-ci.yml file to be the same.

The only difference is three environment variables, all of which are defined in the .gitlab-ci.yml file presently.

My question is this: Is it possible to have variables which are different depending on the branch in question? I see it is possible to specify different jobs for different branches, but that isn’t necessary. There is also the whole business of “environments” which I find overly complex for what it is I want to do here. And after combing through the docs for environments Im still not sure how I would use them to accomplish this without duplicating my job declarations.

Is branch-dependent variables a feature?