Question

I have been having pull request failing on Travis/SauceLabs while the merge build works good. When I get a pull request Travis fails with this code:

ERROR [launcher.sauce]: Can not start chrome (linux)
  Failed to start Sauce Connect:
  Could not start Sauce Connect. Exit code 1 signal: null

How can I test incoming pull requests just on Travis and test a merge on SauceLabs?

Was it helpful?

Solution

It's not possible yet to run pull requests on Sauce Labs when the sauce key/pass are encrypted. This is for safety reasons to not expose the credentials in case the PR has malicious code.

So what is possible is to use the

process.env.TRAVIS_PULL_REQUEST // (string)

to distinguish a pull request from a push/merge triggered test.

So, since this enviroment variable gives you a string with the pull request number or with "false", its possible to use it as a flag. So I used this on my Gruntfile:

var pullRequest = process.env.TRAVIS_PULL_REQUEST;
tasks =  pullRequest != 'false' ? 'karma:continuous' : 'karma:sauceTask';
grunt.registerTask('default:travis', tasks);

and in my :continuous task I have only PhantomJS

        continuous: {
            browsers: ['PhantomJS']
        },
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top