Reputation: 12890
I am able to create specific variables for a branch with travis-ci settings. Is there a way to achieve the same behavior with .travis.yml?
The prior answer was no(see the answer). But looks like it can be outdated nowadays.
Upvotes: 1
Views: 1214
Reputation:
What DannyB is saying certainly makes sense and you should be familiar with it. However, in my setup, I am currently doing it this way, taking advantage of the env section in the .travis.yml file:
env:
- PATH_TO_MY_BINARY=/tmp/bin
As currently seen in the dev/nightly version of my repo
I hope that would be helpful, in spite of bringing this post back from the dead.
Upvotes: 0
Reputation: 14776
Reading the documentation on environment variables, it seems like the answer is stlil no.
They say:
Keep in mind that the definition of environment variables in the Travis UI (as opposed to the .travis.yml
) is intended to keep secrets that are not stored in source control.
It would seem like you have at least two options to play with:
.travis.yml
file.source
ed in before_script
, and have this script set different variables based on the $TRAVIS_BRANCH
environment variable (or any other logic, or any other travis environment variable).Something like that (untested, but I believe a variation of this should work):
# .travis.yml
before_script: source env-vars.sh
# env-vars.sh
if [[ "$TRAVIS_BRANCH" == "master" ]]; then
export MY_VAR=master
else
export MY_VAR=not-master
fi
Upvotes: 1