npm run e2e build在60分钟超时后在CI中失败而没有提供实际错误

时间:2018-06-18 13:16:10

标签: angular typescript tfs protractor azure-pipelines

我的e2e脚本在构建超时后在TFS CI中失败,并且它没有向我显示根本原因。它在构建中随机传递。相同的脚本在本地很好地传递。请帮帮我。

2018-06-15T20:39:06.9176120Z Task         : npm
2018-06-15T20:39:06.9176120Z Description  : Install and publish npm packages, or run an npm command. Supports npmjs.com and authenticated registries like Package Management.
2018-06-15T20:39:06.9176120Z Version      : 1.0.15
2018-06-15T20:39:06.9176120Z Author       : Microsoft Corporation
2018-06-15T20:39:06.9176120Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613746)
2018-06-15T20:39:06.9176120Z ==============================================================================
2018-06-15T20:39:07.6364074Z [command]C:\windows\system32\cmd.exe /D /S /C ""C:\Program Files\nodejs\npm.cmd" --version"
2018-06-15T20:39:08.7927113Z 5.6.0
2018-06-15T20:39:11.2928469Z [command]C:\windows\system32\cmd.exe /D /S /C ""C:\Program Files\nodejs\npm.cmd" config list"
2018-06-15T20:39:12.5585368Z npm info it worked if it ends with ok
2018-06-15T20:39:12.5585368Z ; cli configs
2018-06-15T20:39:12.5585368Z metrics-registry = "https://registry.npmjs.org/"
2018-06-15T20:39:12.5585368Z scope = ""
2018-06-15T20:39:12.5585368Z user-agent = "npm/5.6.0 node/v8.9.4 win32 x64"
2018-06-15T20:39:12.5585368Z 
2018-06-15T20:39:12.5585368Z ; environment configs
2018-06-15T20:39:12.5585368Z loglevel = "verbose"
2018-06-15T20:39:12.5585368Z userconfig = "E:\\Agents\\On-Premise\\vsts-agent-win7-x64-2.124.0\\_work\\27\\npm\\15364.npmrc"
2018-06-15T20:39:12.5585368Z 
2018-06-15T20:39:12.5585368Z ; node bin location = C:\Program Files\nodejs\node.exe
2018-06-15T20:39:12.5585368Z ; cwd = E:\Agents\On-Premise\vsts-agent-win7-x64-2.124.0\_work\27\s
2018-06-15T20:39:12.5585368Z ; HOME = C:\Users\WebSolutionsBldAgent
2018-06-15T20:39:12.5585368Z ; "npm config ls -l" to show all defaults.
2018-06-15T20:39:12.5585368Z 
2018-06-15T20:39:12.5585368Z npm verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
2018-06-15T20:39:12.5585368Z npm verb cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
2018-06-15T20:39:12.5585368Z npm verb cli   'prefix',
2018-06-15T20:39:12.5585368Z npm verb cli   '-g' ]
2018-06-15T20:39:12.5585368Z npm info using npm@5.6.0
2018-06-15T20:39:12.5585368Z npm info using node@v8.9.4
2018-06-15T20:39:12.5585368Z npm verb exit [ 0, true ]
2018-06-15T20:39:12.5585368Z npm info ok 
2018-06-15T20:39:12.5585368Z npm info it worked if it ends with ok
2018-06-15T20:39:12.5585368Z npm verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
2018-06-15T20:39:12.5585368Z npm verb cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
2018-06-15T20:39:12.5585368Z npm verb cli   'config',
2018-06-15T20:39:12.5585368Z npm verb cli   'list' ]
2018-06-15T20:39:12.5585368Z npm info using npm@5.6.0
2018-06-15T20:39:12.5585368Z npm info using node@v8.9.4
2018-06-15T20:39:12.5585368Z npm verb exit [ 0, true ]
2018-06-15T20:39:12.5585368Z npm info ok 
2018-06-15T20:39:12.5741635Z [command]C:\windows\system32\cmd.exe /D /S /C ""C:\Program Files\nodejs\npm.cmd" run e2e"
2018-06-15T21:08:39.2025896Z ##[error]The operation was canceled.
2018-06-15T21:08:39.2025896Z ##[section]Async Command Start: Telemetry
2018-06-15T21:08:39.2025896Z ##[section]Async Command End: Telemetry

2018-06-15T20:39:06.9176120Z

**My Package.json**
{
  "name": "consumer-portal",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "serve": "ng lint && ng serve -o",
    "serve.dev": "node set-env.js --env=dev && ng lint && ng serve -o",
    "serve.test": "node set-env.js --env=test && ng lint && ng serve -o",
    "serve.prod": "node set-env.js --env=prod && ng lint && ng serve -o",
    "serve.local": "node set-env.js --env=local && ng lint && ng serve -o",
    "serve.staging": "node set-env.js --env=staging && ng lint && ng serve -o",
    "build.test-server": "node set-env.js --env=dev && ng build --stats-json",
    "build.dev": "update-modules.bat && node set-env.js --env=dev && ng build --env=dev --prod=true --aot=false --stats-json",
    "build.test": "node set-env.js --env=test && ng build --env=test --stats-json",
    "build.staging": "node set-env.js --env=staging && ng build --env=staging --stats-json",
    "build.prod": "node set-env.js --env=prod && ng build --env=prod --stats-json",
    "test": "ng lint && ng test",
    "ci.test": "ng lint && ng test --singleRun",
    "lint": "ng lint",
    "e2e": "webdriver-manager update --ignore_ssl && ng lint && ng e2e",
    "bundle-report": "webpack-bundle-analyzer dist/stats.json"
  },


  "devDependencies": {
    "@angular-devkit/schematics": "^0.5.7",
    "@angular/cli": "^1.7.4",
    "@angular/compiler-cli": "^5.2.10",
    "@angular/language-service": "^5.2.10",
    "@schematics/angular": "^0.5.7",
    "@types/jasmine": "2.5.45",
    "@types/node": "8.0.53",
    "autoprefixer": "^6.5.3",
    "circular-dependency-plugin": "^3.0.0",
    "codelyzer": "~3.0.1",
    "copy-webpack-plugin": "^4.2.3",
    "css-loader": "^0.28.7",
    "cssnano": "^3.10.0",
    "exports-loader": "^0.6.3",
    "file-loader": "^0.10.0",
    "html-webpack-plugin": "^2.30.1",
    "istanbul-instrumenter-loader": "^2.0.0",
    "jasmine-core": "~2.6.2",
    "jasmine-reporters": "^2.3.1",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "~1.7.0",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-ie-launcher": "^1.0.0",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "karma-junit-reporter": "^1.2.0",
    "less-loader": "^4.0.5",
    "node-sass": "^4.7.2",
    "postcss-loader": "^2.0.9",
    "postcss-url": "^7.3.0",
    "protractor": "^5.1.2",
    "protractor-jasmine2-html-reporter": "0.0.7",
    "raw-loader": "^0.5.1",
    "sass-loader": "^6.0.3",
    "source-map-loader": "^0.2.0",
    "style-loader": "^0.13.1",
    "stylus-loader": "^3.0.1",
    "ts-node": "~3.3.0",
    "tslint": "~5.3.2",
    "typescript": "^2.8.1",
    "url-loader": "^0.6.0",
    "webpack": "~3.9.0",
    "webpack-bundle-analyzer": "^2.11.1",
    "webpack-concat-plugin": "1.4.2",
    "webpack-dev-server": "~2.9.5"
  }
}

2018-06-15T21:08:39.2025896Z ## [section]整理:npm run e2e tests

const { SpecReporter } = require('jasmine-spec-reporter');
const Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');
var jasmineReporters = require('jasmine-reporters');

exports.config = {

  baseurl:'https://consumertst.workpartners.com/login.html',  
  allScriptsTimeout: 60000,
  getPageTimeout: 60000  ,
  ignoreUncaughtExceptions: true,
  specs: [
    './e2e/**/*.e2e-spec.ts'
  ],

  /*  jvmArgs: ['-Dwebdriver.ie.driver=./IEDriverServer_Win32_3.4.0.exe'],
  seleniumAddress: 'http://127.0.0.1:4444/wd/hub',

  capabilities: {
      'browserName': 'internet explorer',
      'version': '11',
      'nativeEvents': false,
      'unexpectedAlertBehaviour': 'accept',
      'ignoreProtectedModeSettings': true,
      'disable-popup-blocking': true,
      'enablePersistentHover': true
  },*/
  capabilities: {        
      'browserName': 'chrome',
      'chromeOptions': {'args' : ['incognito']},
  },

  shardTestFiles: false,
    // Maximum number of browser instances that can run in parallel for this
    // set of capabilities. This is only needed if shardTestFiles is true.
    // Default is 1.
  maxInstances: 1,
  directConnect: true,

  framework: 'jasmine',
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 2500000,
    print: function () { }
  },

  beforeLaunch: () => {
    require('ts-node').register({
      project: 'e2e/tsconfig.e2e.json'});
  },

  onPrepare() {
    jasmine.getEnv().addReporter(new SpecReporter({
      spec: { 
        displayStacktrace: true }
    }));
    jasmine.getEnv().addReporter(new Jasmine2HtmlReporter({
        savePath: './test/reports/',
        screenshotsFolder: 'images',
        takeScreenshots: true,
        takeScreenshotsOnlyOnFailures: true
    }));
    jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
      consolidateAll: true,
      savePath: 'testresults',
      filePrefix: 'protractor-test-results',
      modifySuiteName: function (generatedSuiteName, suite) {
        return 'e2e.' + generatedSuiteName; // whichever prefix you wish to use
      }
    }));

    browser.manage().window().maximize();
    browser.manage().timeouts().implicitlyWait(20000);
  }
};

protractor.conf.js

<% flash.each do |key, value| %>
 <% unless key.to_s == 'timedout' %>
    <div class="alert alert-<%= key %>">
      <a href="#" data-dismiss="alert" class="close">×</a>
      <ul style="list-style-type: none;">
        <li>
          <%= value %>
        </li>
      </ul>
    </div>
 <% end %>
 <% end %>

.alert-alert
  margin-top: 10px
  background-color: #ffffff
  border-color: #ffffff
  color: #b94a48
  text-align: center


.alert-success
   margin-top: 10px
   color: #317EAC
   background-color: #f5f5f5
   border-color: #f5f5f5
   text-align: center


.alert-notice
  top: -10px
  color: #317EAC
  background-color: #ffffff
  border-color: #ffffff
  text-align: center

.alert
  height: 100%
  width: 100%
  line-height: 14px

.close
  height: 100%
  line-height: 14px

1 个答案:

答案 0 :(得分:0)

我从您的protractor.conf.js中看到您正在使用directConnect来使Protractor在本地启动chrome。这通常会在CI环境中导致问题,因为CI可能不支持任何类型的图形界面。通常在CI环境中,人们使用SauceLabs或BrowserStack之类的服务来托管其硒服务器,然后使用sauceUser/sauceKeybrowserstackUser/browserstackKey字段将量角器指向该远程硒服务器。

也就是说,有很多事情可能出错(例如,webdriver-manager update可能由于某种原因而失败),这很可能是那种只能亲自亲自调试的问题。< / p>

根据我的经验,在这种情况下,最好的做法是寻求同事的帮助。找到在您的TFS CI环境中有调试问题的经验的人,并询问他们是否有时间与您坐在一起,并帮助您解决该问题。如果您不知道谁有这种经验,可以作为经理或团队中的某人,如果他们认识任何人,或者他们知道如何寻找某人。