最初的免责声明 - 我
我正在尝试设置一个Jenkins工作,以完成我在无头版Chrome中为我的网络应用程序编写的一系列端到端测试,我亲眼目睹并阅读了PhantomJS相当不可靠。我可以让它们在我的机器上本地运行绝对正常,但是当我尝试在Jenkins上运行它时,我会用下面的内容回来:
错误日志
[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
我已经在黑暗中磕磕绊绊地待了一天左右现在已经尝试了几乎100种不同的组合,互联网说应该修复它,但无济于事。
我的Jenkins文件
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());
}
};
如果有人能够解释为什么会这样,以及如何阻止它这样做,那将非常感激。
提前致谢!
修改 这是我没有直接连接时的输出
[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