最初的免责声明 - 我对詹金斯很陌生,所以我还没有真正了解它。婴儿步将不胜感激。
我正在尝试设置 Jenkins 作业,以运行我在 Chrome 的无头版本中为我的 Web 应用程序编写的一系列端到端测试,因为我目睹并读到 PhantomJS 相当不可靠. 我可以让它们在我的机器上本地运行得非常好,但是当我尝试在 Jenkins 上运行它时,它会返回以下内容:
错误日志
[13:25:24] I/file_manager - 创建文件夹 /var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDI2LYG4RGOVBQ/node_modules/protractor/node_modules/webdriver-manager/selenium [13:25:24] I/update - chromedriver:解压 chromedriver_2.30.zip [13:25:24] I/更新 - chromedriver:将 /var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDI2LYG4RGOVBQ/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.30 的权限设置为 0755 [13:25:24] I/launcher - 运行 1 个 WebDriver 实例 [13:25:24] I/direct - 直接使用 ChromeDriver... [13:25:25] E/launcher - 服务器提前终止,状态为 127 [13:25:25] E/launcher - 错误:服务器提前终止,状态为 127 在 earlyTermination.catch.e (/var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDI2LYG4RGOVBQ/node_modules/selenium-webdriver/remote/index.js:252:52) 在 process._tickCallback (internal/process/next_tick.js:103:7) 来自:任务:WebDriver.createSession() 在 Function.createSession (/var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDI2LYG4RGOVBQ/node_modules/selenium-webdriver/lib/webdriver.js:777:24) 在 Function.createSession (/var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDI2LYG4RGOVBQ/node_modules/selenium-webdriver/chrome.js:709:29) 在 Direct.getNewDriver (/var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDI2LYG4RGOVBQ/node_modules/protractor/lib/driverProviders/direct.ts:90:25) 在 Runner.createBrowser (/var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDI2LYG4RGOVBQ/node_modules/protractor/lib/runner.ts:225:39) 在 q.then.then (/var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDI2LYG4RGOVBQ/node_modules/protractor/lib/runner.ts:391:27) 在 _fulfilled (/var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDI2LYG4RGOVBQ/node_modules/protractor/node_modules/q/q.js:834:54) 在 self.promiseDispatch.done (/var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDI2LYG4RGOVBQ/node_modules/protractor/node_modules/q/q.js:863:30) 在 Promise.promise.promiseDispatch (/var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDI2LYG4RGOVBQ/node_modules/protractor/node_modules/q/q.js:796:13) 在 /var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDVI2LYG4RGOVBQ/node_modules/protractor/node_modules/q/q.js:556:49 在 runSingle (/var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDI2LYG4RGOVBQ/node_modules/protractor/node_modules/q/q.js:137:13) 冲洗时(/var/jenkins/workspace/Web_App_feature_e2e-chrome-YUH5PYKKXHHXSQT3HLIZ74DQIBAH3D5D6WZCOLDI2LYG4RGOVBQ/node_modules/protractor/node_modules/q/q.js:125:13) 在 _combinedTickCallback (internal/process/next_tick.js:67:7) 在 process._tickCallback (internal/process/next_tick.js:98:9) [13:25:25] E/launcher - 进程退出,错误代码 199 [管道] } [管道] // 阶段 [管道] } [管道] // 节点 [管道] 管道结束 [Bitbucket] 通知提交构建结果 [Bitbucket] 构建结果通知 错误:脚本返回退出代码 199 完成:失败
我已经在黑暗中摸索了一天左右,并尝试了近 100 种不同的互联网所说的应该解决它的组合,但无济于事..
我的詹金斯文件
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
}
}
量角器.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