title: Jenkins CI E2E test process failing with code 127, then 199 (or 135)
body: <p>Initial disclaimer - I'm <em>very</em> new to Jenkins so I don't really get much about it yet.  Baby steps would be appreciated very muchly.</p>
  
  <p>I'm in the process of trying to set up a Jenkins job to run through a series of end to end tests I've written for my web app in a headless version of Chrome, as I have witnessed and read that PhantomJS is rather unreliable.  I can get them to run absolutely fine locally on my machine, but when I try to run it on Jenkins I get it come back with the below:</p>
  
  <p><strong>The error log</strong></p>
  
  <pre>
      [13:25:24] I/file_manager - creating folder /var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDVI2LYG4RGOVBQ/node_modules/protractor/node_modules/webdriver-manager/selenium
      [13:25:24] I/update - chromedriver: unzipping chromedriver_2.30.zip
      [13:25:24] I/update - chromedriver: setting permissions to 0755 for /var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDVI2LYG4RGOVBQ/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.30
      [13:25:24] I/launcher - Running 1 instances of WebDriver
      [13:25:24] I/direct - Using ChromeDriver directly...
      [13:25:25] E/launcher - Server terminated early with status 127
      [13:25:25] E/launcher - Error: Server terminated early with status 127
          at earlyTermination.catch.e (/var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDVI2LYG4RGOVBQ/node_modules/selenium-webdriver/remote/index.js:252:52)
          at process._tickCallback (internal/process/next_tick.js:103:7)
      From: Task: WebDriver.createSession()
          at Function.createSession (/var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDVI2LYG4RGOVBQ/node_modules/selenium-webdriver/lib/webdriver.js:777:24)
          at Function.createSession (/var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDVI2LYG4RGOVBQ/node_modules/selenium-webdriver/chrome.js:709:29)
          at Direct.getNewDriver (/var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDVI2LYG4RGOVBQ/node_modules/protractor/lib/driverProviders/direct.ts:90:25)
          at Runner.createBrowser (/var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDVI2LYG4RGOVBQ/node_modules/protractor/lib/runner.ts:225:39)
          at q.then.then (/var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDVI2LYG4RGOVBQ/node_modules/protractor/lib/runner.ts:391:27)
          at _fulfilled (/var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDVI2LYG4RGOVBQ/node_modules/protractor/node_modules/q/q.js:834:54)
          at self.promiseDispatch.done (/var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDVI2LYG4RGOVBQ/node_modules/protractor/node_modules/q/q.js:863:30)
          at Promise.promise.promiseDispatch (/var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDVI2LYG4RGOVBQ/node_modules/protractor/node_modules/q/q.js:796:13)
          at /var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDVI2LYG4RGOVBQ/node_modules/protractor/node_modules/q/q.js:556:49
          at runSingle (/var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDVI2LYG4RGOVBQ/node_modules/protractor/node_modules/q/q.js:137:13)
          at flush (/var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDVI2LYG4RGOVBQ/node_modules/protractor/node_modules/q/q.js:125:13)
          at _combinedTickCallback (internal/process/next_tick.js:67:7)
          at process._tickCallback (internal/process/next_tick.js:98:9)
      [13:25:25] E/launcher - Process exited with error code 199
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      [Bitbucket] Notifying commit build result
      [Bitbucket] Build result notified
      ERROR: script returned exit code 199
      Finished: FAILURE
  </pre>
  
  <p>I've been stumbling around in the dark with these for a day or so now and have tried almost 100 different combinations of what the internet says should fix it, but to no avail..</p>
  
  <p><strong>My Jenkinsfile</strong></p>
  
  <pre><code>properties([[$class: 'jenkins.model.BuildDiscarderProperty',
               strategy: [$class: 'LogRotator', numToKeepStr: '30', artifactNumToKeepStr: '1']]])
  
  node('web-app-build') {
    try {
  
      stage('Clean workspace') {
          deleteDir()
      }
  
      stage('Install NodeJS and NPM') {
          def nodeHome = tool name: 'NodeJS 7.2.0', type: 'jenkins.plugins.nodejs.tools.NodeJSInstallation'
          env.PATH = "${nodeHome}/bin:${env.PATH}"
      }
  
      stage('Checkout') {
          checkout scm
      }
  
      stage('Install Dependencies') {
          sh "npm install --silent"
          sh "npm install -g @angular/cli@latest"
          sh "ng set --global warnings.versionMismatch=false"
  
          sh "npm install protractor -g"
  
      }
  
      stage('Run E2E tests') {
          sh "webdriver-manager update --versions.chrome=2.30 --gecko=false"
          sh "ng e2e"
      }
  
      stage('Publish Reports') {
          publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: 'coverage', reportFiles: 'index.html', reportName: 'HTML Report'])
          step([$class: 'JUnitResultArchiver', testResults: '**/junit/junit.xml'])
          step([
              $class: 'CloverPublisher',
              cloverReportDir: 'coverage',
              cloverReportFileName: 'clover.xml',
              healthyTarget: [methodCoverage: 70, conditionalCoverage: 80, statementCoverage: 80],
              unhealthyTarget: [methodCoverage: 50, conditionalCoverage: 50, statementCoverage: 50],
              failingTarget: [methodCoverage: 0, conditionalCoverage: 0, statementCoverage: 0]
            ])
      }
  
      if (env.BRANCH_NAME == 'develop') {
  
          stage('Create env=staging build ready for S3') {
              sh "ng build --env=staging --output-hashing=all"
          }
  
          stage('Deploy Build to S3 -----------------') {
              env.AWS_ACCESS_KEY_ID = '------------------------'
              env.AWS_SECRET_ACCESS_KEY = '------------------------'
  
              sh "npm install s3-deploy -g"
              sh "s3-deploy 'dist/**' --cwd './dist' --region 'us-west-2' --bucket '-----------------' --cache 60 --etag"
          }
  
          stage('Create env=ci build ready for S3') {
             sh "ng build --env=ci --output-hashing=all"
          }
  
          stage('Deploy Build to S3 ---------------') {
              env.AWS_ACCESS_KEY_ID = '--------------------'
              env.AWS_SECRET_ACCESS_KEY = '---------------------'
  
              sh "npm install s3-deploy -g"
              sh "s3-deploy 'dist/**' --cwd './dist' --region 'us-west-2' --bucket '-----------------------' --cache 60 --etag"
          }
  
          stage('Create env=e2e build ready for S3 ------------------') {
             sh "ng build --env=e2e --output-hashing=all"
          }
  
          stage('Deploy Build to S3 ------------------') {
              env.AWS_ACCESS_KEY_ID = '-----------------------'
              env.AWS_SECRET_ACCESS_KEY = '--------------------------'
  
              sh "npm install s3-deploy -g"
              sh "s3-deploy 'dist/**' --cwd './dist' --region 'us-west-2' --bucket '-------------------------' --cache 60 --etag"
          }
  
          stage('Run "Web App e2e" Tests') {
              build job: '../Web App e2e', wait: false
          }
      }
  
    } catch (e) {
      throw e
    }
  
  }
  </code></pre>
  
  <p><strong>protractor.conf.js</strong></p>
  
  <pre><code>/*global jasmine */
  var SpecReporter = require('jasmine-spec-reporter').SpecReporter;
  
  exports.config = {
      allScriptsTimeout: 11000,
      specs: [
          './e2e/**/*.e2e-spec.ts'
      ],
  
      capabilities: {
          'browserName': 'chrome',
          'chromeOptions': {
              args: ['--headless', 'no-sandbox', '--disable-gpu', '--window-size=800x600']
          }
      },
      directConnect: true,
      framework: 'jasmine',
      jasmineNodeOpts: {
          showColors: true,
          defaultTimeoutInterval: 30000,
          print: function () {
          }
      },
      useAllAngular2AppRoots: true,
      beforeLaunch: function () {
          require('ts-node').register({
              project: 'e2e'
          });
      },
      onPrepare: function () {
          jasmine.getEnv().addReporter(new SpecReporter());
      }
  };
  </code></pre>
  
  <p>If someone could explain why this is happening, and how to stop it from doing so, that would be much appreciated.</p>
  
  <p>Thanks in advance!</p>
  
  <p><strong>EDIT</strong>
  This is the output when I don't connect directly</p>
  
  <pre><code>[15:03:50] I/file_manager - creating folder /var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDVI2LYG4RGOVBQ/node_modules/protractor/node_modules/webdriver-manager/selenium
  [15:03:51] I/update - chromedriver: unzipping chromedriver_2.30.zip
  [15:03:51] I/update - chromedriver: setting permissions to 0755 for /var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDVI2LYG4RGOVBQ/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.30
  [15:03:51] I/launcher - Running 1 instances of WebDriver
  [15:03:51] E/local - Error code: 135
  [15:03:51] E/local - Error message: No update-config.json found. Run 'webdriver-manager update' to download binaries.
  [15:03:51] E/local - Error: No update-config.json found. Run 'webdriver-manager update' to download binaries.
      at Local.addDefaultBinaryLocs_ (/var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDVI2LYG4RGOVBQ/node_modules/protractor/lib/driverProviders/local.ts:47:15)
      at Local.setupDriverEnv (/var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDVI2LYG4RGOVBQ/node_modules/protractor/lib/driverProviders/local.ts:98:10)
      at Local.setupEnv (/var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDVI2LYG4RGOVBQ/node_modules/protractor/lib/driverProviders/driverProvider.ts:124:30)
      at q.then (/var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDVI2LYG4RGOVBQ/node_modules/protractor/lib/runner.ts:387:39)
      at _fulfilled (/var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDVI2LYG4RGOVBQ/node_modules/protractor/node_modules/q/q.js:834:54)
      at self.promiseDispatch.done (/var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDVI2LYG4RGOVBQ/node_modules/protractor/node_modules/q/q.js:863:30)
      at Promise.promise.promiseDispatch (/var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDVI2LYG4RGOVBQ/node_modules/protractor/node_modules/q/q.js:796:13)
      at /var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDVI2LYG4RGOVBQ/node_modules/protractor/node_modules/q/q.js:857:14
      at runSingle (/var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDVI2LYG4RGOVBQ/node_modules/protractor/node_modules/q/q.js:137:13)
      at flush (/var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDVI2LYG4RGOVBQ/node_modules/protractor/node_modules/q/q.js:125:13)
      at _combinedTickCallback (internal/process/next_tick.js:67:7)
      at process._tickCallback (internal/process/next_tick.js:98:9)
  [15:03:51] E/launcher - Process exited with error code 135
  [Pipeline] }
  [Pipeline] // stage
  [Pipeline] }
  [Pipeline] // node
  [Pipeline] End of Pipeline
  [Bitbucket] Notifying commit build result
  [Bitbucket] Build result notified
  ERROR: script returned exit code 135
  Finished: FAILURE
  </code></pre>