1

Initial disclaimer - I'm very new to Jenkins so I don't really get much about it yet. Baby steps would be appreciated very muchly.

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:

The error log

    [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

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..

My Jenkinsfile

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
  }

}

protractor.conf.js

/*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());
    }
};

If someone could explain why this is happening, and how to stop it from doing so, that would be much appreciated.

Thanks in advance!

EDIT This is the output when I don't connect directly

[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
030
  • 10,842
  • 12
  • 78
  • 123
Olly John
  • 366
  • 5
  • 20
  • After further reading your question, you will want to drop your install section (most likely it is not doing what you are expecting it to do, and this varies by system as to how you would install NodeJS). Check https://stackoverflow.com/questions/42261382/jenkins-pipeline-select-nodejs-version-python-version for some info on selecting a nodeJS version, if you are more interested in ensuring a specific version of Node is being used. – Roy Folkker Jul 17 '17 at 16:19
  • I've now installed node, NPM, the angular CLI, protractor and chrome-launcher on the machine itself (I found out I could ssh onto it and run commands directly on there to save time) and this seems to have got past this issue. I am, however, now getting the below error output: `E/launcher - unknown error: unrecognized Chrome version: HeadlessChrome/59.0.3071.115` Do you have any suggestions on how to get past this? – Olly John Jul 18 '17 at 13:34
  • It looks like you may be pointing to a bad ChromeDriver. Make sure you are running the latest chrome driver. Check: https://sites.google.com/a/chromium.org/chromedriver/downloads – Roy Folkker Jul 18 '17 at 15:52
  • Yeah, I got it sorted in the end. Turned out I'd manually told webdriver-manager to use 2.26 in the Jenkinsfile and headless chrome's only supported from 2.29 onward I think, so it wasn't liking it. Took that out and it's all running fine now. Thanks for your help! – Olly John Jul 19 '17 at 07:15

0 Answers0