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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With