我是詹金斯的新人。我想在詹金斯(Jenkins)工作中自动运行我的量角器测试。
这是我的package.js文件:
{
"name": "ui",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "5.2.0",
"@angular/common": "5.2.0",
"@angular/compiler": "5.2.0",
"@angular/core": "5.2.0",
"@angular/forms": "5.2.0",
"@angular/http": "5.2.11",
"@angular/platform-browser": "5.2.0",
"@angular/platform-browser-dynamic": "5.2.0",
"@angular/router": "5.2.0",
"bootstrap": "4.1.1",
"core-js": "2.4.1",
"jquery": "3.3.1",
"ngx-bootstrap": "^3.0.1",
"popper.js": "^1.14.3",
"protractor-jasmine2-html-reporter": "0.0.7",
"protractor-jasmine2-reporter": "^1.1.0",
"protractor-jasmine2-screenshot-reporter": "^0.5.0",
"rxjs": "5.5.6",
"zone.js": "0.8.19"
},
"devDependencies": {
"@angular/cli": "1.7.3",
"@angular/compiler-cli": "5.2.0",
"@angular/language-service": "5.2.0",
"@types/jasmine": "2.8.3",
"@types/jasminewd2": "2.0.2",
"@types/node": "6.0.60",
"codelyzer": "4.0.1",
"jasmine-core": "2.8.0",
"jasmine-spec-reporter": "4.2.1",
"karma": "2.0.2",
"karma-chrome-launcher": "2.2.0",
"karma-coverage-istanbul-reporter": "1.2.1",
"karma-jasmine": "1.1.0",
"karma-jasmine-html-reporter": "0.2.2",
"protractor": "5.3.2",
"ts-node": "4.1.0",
"tslint": "5.9.1",
"typescript": "2.5.3"
}
}
这是我的protractor.confing.js:
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
],
seleniumAddress: 'http://HubDomain-IP:4444/wd/hub',
//Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome',
// add node-name as applicationName where you have started node and wanted to remotely execute test cases
'applicationName': 'remoteNode'
},
chromeDriver: 'C:/Users/<username>/AppData/Roaming/npm/node_modules/protractor/selenium/chromedriver.exe',
seleniumServerJar: 'C:/Users/<username>/AppData/Roaming/npm/node_modules/protractor/selenium/selenium-server-standalone-2.40.0.jar',
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function () { }
},
suites: {
full: 'e2e/**/**/*.ts',
powerMax200: 'e2e/tests/powerMax2000/*.ts',
powerMax200: 'e2e/tests/powerMax8000/*.ts',
vmax250f: 'e2e/tests/vmax250f/*.ts',
vmax950f: 'e2e/tests/vmax950f/*.ts'
},
onPrepare() {
var Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');
require('ts-node').register({
// project: 'e2e/tsconfig.e2e.json',
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
jasmine.getEnv().addReporter(new Jasmine2HtmlReporter({
savePath: './e2e/report',
screenshotsFolder: 'images'
}));
}
};
在我的Jenkins工作中,我从BitBucket存储库中提取代码。然后执行Windows批处理命令: 1)cd NewGenProject / ui / npm install
2)cd NewGenProject / ui / npm -g安装量角器
3)cd NewGenProject / ui /
npm install -g @ angular / cli ./node_modules.bin\webdriver-manager更新
我在控制台中出错:
Started by user Admin
Building in workspace C:\Program Files (x86)\Jenkins\workspace\newGen_protractor
> C:\Program Files\Git\bin\git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> C:\Program Files\Git\bin\git.exe config remote.origin.url https://___somi@bitbucket.org/night_riders/desingstudio_new_gen.git # timeout=10
Fetching upstream changes from https://___somi@bitbucket.org/night_riders/desingstudio_new_gen.git
> C:\Program Files\Git\bin\git.exe --version # timeout=10
using GIT_ASKPASS to set credentials
> C:\Program Files\Git\bin\git.exe fetch --tags --progress https://___somi@bitbucket.org/night_riders/desingstudio_new_gen.git +refs/heads/*:refs/remotes/origin/*
Seen branch in repository origin/application.properties
Seen branch in repository origin/develop
Seen branch in repository origin/master
Seen 3 remote branches
> C:\Program Files\Git\bin\git.exe show-ref --tags -d # timeout=10
Checking out Revision 4af5b739aa52943c28f58d128d5f28bffa095463 (origin/application.properties)
> C:\Program Files\Git\bin\git.exe config core.sparsecheckout # timeout=10
> C:\Program Files\Git\bin\git.exe checkout -f 4af5b739aa52943c28f58d128d5f28bffa095463
Commit message: "a"
> C:\Program Files\Git\bin\git.exe rev-list --no-walk 4af5b739aa52943c28f58d128d5f28bffa095463 # timeout=10
System is not Unix, Xvfb will not be started
[newGen_protractor] $ cmd /c call C:\Windows\TEMP\jenkins205557989357167568.bat
C:\Program Files (x86)\Jenkins\workspace\newGen_protractor>cd NewGenProject/ui/
C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui>npm install
npm WARN @angular/http@5.2.11 requires a peer of @angular/core@5.2.11 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/http@5.2.11 requires a peer of @angular/platform-browser@5.2.11 but none is installed. You must install peer dependencies yourself.
npm WARN ngx-bootstrap@3.0.1 requires a peer of @angular/common@>=6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN ngx-bootstrap@3.0.1 requires a peer of @angular/core@>=6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
audited 7548 packages in 39.325s
found 8 vulnerabilities (2 low, 5 moderate, 1 high)
run `npm audit fix` to fix them, or `npm audit` for details
[newGen_protractor] $ cmd /c call C:\Windows\TEMP\jenkins6721521287779075208.bat
C:\Program Files (x86)\Jenkins\workspace\newGen_protractor>cd NewGenProject/ui/
C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui>npm -g install protractor
C:\Windows\system32\config\systemprofile\AppData\Roaming\npm\protractor -> C:\Windows\system32\config\systemprofile\AppData\Roaming\npm\node_modules\protractor\bin\protractor
C:\Windows\system32\config\systemprofile\AppData\Roaming\npm\webdriver-manager -> C:\Windows\system32\config\systemprofile\AppData\Roaming\npm\node_modules\protractor\bin\webdriver-manager
+ protractor@5.4.1
updated 1 package in 15.574s
[newGen_protractor] $ cmd /c call C:\Windows\TEMP\jenkins3967655168792638034.bat
C:\Program Files (x86)\Jenkins\workspace\newGen_protractor>cd NewGenProject/ui/
C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui>npm install -g @angular/cli
C:\Windows\system32\config\systemprofile\AppData\Roaming\npm\ng -> C:\Windows\system32\config\systemprofile\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\@angular\cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ @angular/cli@6.2.2
updated 1 package in 41.598s
[newGen_protractor] $ cmd /c call C:\Windows\TEMP\jenkins7519801179326584034.bat
C:\Program Files (x86)\Jenkins\workspace\newGen_protractor>cd NewGenProject/ui/
C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui>ng e2e --no-webdriver-update
Your global Angular CLI version (6.2.1) is greater than your local
version (1.7.3). The local Angular CLI version is used.
To disable this warning use "ng config -g cli.warnings.versionMismatch false".
** NG Live Development Server is listening on localhost:49156, open your browser on http://localhost:49156/ **
[0mDate: [1m[37m2018-09-18T11:33:38.940Z[39m[22m[0m
[0mHash: [1m[37mb824d4ffc831966e2310[39m[22m[0m
[0mTime: [1m[37m32450[39m[22mms[0m
[0mchunk {[1m[33minline[39m[22m} [1m[32minline.bundle.js, inline.bundle.js.map[39m[22m (inline) 3.89 kB [1m[33m[entry][39m[22m[1m[32m [rendered][39m[22m[0m
[0mchunk {[1m[33mmain[39m[22m} [1m[32mmain.bundle.js, main.bundle.js.map[39m[22m (main) 240 kB [1m[33m[initial][39m[22m[1m[32m [rendered][39m[22m[0m
[0mchunk {[1m[33mpolyfills[39m[22m} [1m[32mpolyfills.bundle.js, polyfills.bundle.js.map[39m[22m (polyfills) 203 kB [1m[33m[initial][39m[22m[1m[32m [rendered][39m[22m[0m
[0mchunk {[1m[33mscripts[39m[22m} [1m[32mscripts.bundle.js, scripts.bundle.js.map[39m[22m (scripts) 158 kB [1m[33m[initial][39m[22m[1m[32m [rendered][39m[22m[0m
[0mchunk {[1m[33mstyles[39m[22m} [1m[32mstyles.bundle.js, styles.bundle.js.map[39m[22m (styles) 158 kB [1m[33m[initial][39m[22m[1m[32m [rendered][39m[22m[0m
[0mchunk {[1m[33mvendor[39m[22m} [1m[32mvendor.bundle.js, vendor.bundle.js.map[39m[22m (vendor) 6.04 MB [1m[33m[initial][39m[22m[1m[32m [rendered][39m[22m[0m
(node:3240) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
webpack: Compiled successfully.
[13:33:39] I/launcher - Running 1 instances of WebDriver
[13:33:39] I/direct - Using ChromeDriver directly...
[13:33:39] E/direct - Error code: 135
[13:33:39] E/direct - Error message: Could not find update-config.json. Run 'webdriver-manager update' to download binaries.
[13:33:39] E/direct - Error: Could not find update-config.json. Run 'webdriver-manager update' to download binaries.
at Direct.getNewDriver (C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui\node_modules\protractor\built\driverProviders\direct.js:63:31)
at Runner.createBrowser (C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui\node_modules\protractor\built\runner.js:195:43)
at q.then.then (C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui\node_modules\protractor\built\runner.js:339:29)
at _fulfilled (C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui\node_modules\q\q.js:834:54)
at self.promiseDispatch.done (C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui\node_modules\q\q.js:863:30)
at Promise.promise.promiseDispatch (C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui\node_modules\q\q.js:796:13)
at C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui\node_modules\q\q.js:556:49
at runSingle (C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui\node_modules\q\q.js:137:13)
at flush (C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui\node_modules\q\q.js:125:13)
at _combinedTickCallback (internal/process/next_tick.js:132:7)
at process._tickCallback (internal/process/next_tick.js:181:9)
[13:33:39] E/launcher - Process exited with error code 135
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE
答案 0 :(得分:0)
在Jenkins作业中更改以下3行cmd:
cd NewGenProject/ui/
npm install
node_moduels\.bin\ng e2e --webdriver-update