I'm using Travis for javascript (Grunt / Karma) testing and I set some variables in the .travis.yml
file to run an array of tests. What I am missing is a means of defining variables using an if / else.
I'm looking for something like 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'
}
I use the variable% travis $TRAVIS_PULL_REQUEST
to control whether the test is triggered by a Pull Request in GitHub or not. In the case of a Pull Request I want to test the code only with PhantomJS.
Using the above variables without If / Else works, but I wanted to avoid using tests in browsers because they are done in SauceLabs and because the password is encrypted in the%% error log the test fails if the Request Request is from another repository on GitHub for security reasons.