3
I am using Travis for javascript testing (Grunt/Karma) and set some variables in the file .travis.yml
to run a test matrix. What I’m missing is a means of defining variables using an if/Else.
I’m looking for something similar to this logic:
language: node_js
node_js:
- 0.11
env:
matrix:
if ($TRAVIS_PULL_REQUEST == 'false') {
- 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'
}
Use the Travis variable $TRAVIS_PULL_REQUEST
to control whether the test is triggered by a Pull Request on Github or not. In case it is a Pull Request I want to test the code only with Phantomjs.
Using the variables above without If/Else works, but I wanted to avoid using browser tests because these are done in Saucelabs and how the password is surmounted in the database .yml
the test fails if Pull Request is from another repository on Github for security reasons.