Reputation: 28845
Is there a way to use IF
/ELSE
inside the .yml
file?
I wanted to define env
variables if
it's not a pull request.
Something like this idea:
env:
matrix:
if ($TRAVIS_PULL_REQUEST) {
- BROWSER='chrome_linux' BUILD='default'
- BROWSER='chrome_linux' BUILD='nocompat'
- BROWSER='firefox_linux' BUILD='default'
- BROWSER='firefox_linux' BUILD='nocompat'
}
else {
- BROWSER='phantomjs' BUILD='default'
}
Is this possible?
Upvotes: 11
Views: 8745
Reputation: 2663
I don't think this particular case would work. TRAVIS_PULL_REQUEST
is defined on the build worker, while build matrix must be constructed before handing off the job to the worker.
I suggest writing a wrapper script that takes TRAVIS_PULL_REQUEST
and set the environment variables correctly, or do something like this in before_install
:
[ "${TRAVIS_PULL_REQUEST}" != "false" ] && BROWSER='chrome_linux' BUILD='default' || true
Upvotes: 5