You can inspect the branch name with TRAVIS_BRANCH
.
Then, you can use bash indirection to get the value of the environment variable whose name is indicated by the value of TRAVIS_BRANCH
:
$ PROD=1.0.1
$ STAGE=2.0.1
$ TRAVIS_BRANCH="PROD"
$ abc=${!TRAVIS_BRANCH}
$ echo ${abc}
1.0.1