【问题标题】:Run protractor e2e tests from Visual Studio Team Services从 Visual Studio Team Services 运行量角器 e2e 测试
【发布时间】:2018-01-25 15:18:12
【问题描述】:

我在尝试从发布定义中的 VSTS 运行 Protractor e2e 测试时遇到问题。

我在发布定义中的步骤是:

  1. Azure 文件复制:这会将源代码从 Git 存储库复制到将运行测试的 Azure VM

  2. 目标机器上的 PowerShell:这会在 Azure VM 上执行 Powershell 脚本。

powershell脚本如下:

cd c:/App
$ErrorActionPreference = 'Continue'
npm install
npm run e2e

在 VSTS 中,它失败并显示以下错误:

2018-01-24T05:27:47.2854207Z     Deployment started on target machine...
2018-01-24T05:27:47.2854587Z 
2018-01-24T05:27:47.2855184Z System.AggregateException: Failed to execute the powershell script. Consult the logs below for details of the error.
2018-01-24T05:27:47.2855708Z 
2018-01-24T05:27:47.2856210Z System.Management.Automation.RemoteException
2018-01-24T05:27:47.2856743Z  +At C:\scripts\Rune2eTests.ps1:3 char:1
2018-01-24T05:27:47.2857225Z + npm install
2018-01-24T05:27:47.2857694Z + ~~~~~~~~~~~~~~~~~~~~
2018-01-24T05:27:47.2858464Z  CategoryInfo :NotSpecified: (:String) [], RemoteException
2018-01-24T05:27:47.2859049Z  FullyQualifiedErrorId :NativeCommandError
2018-01-24T05:27:47.2859393Z 
2018-01-24T05:27:47.2860037Z Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.
2018-01-24T05:27:47.2860677Z  +At C:\scripts\Rune2eTests.ps1:4 char:1
2018-01-24T05:27:47.2861172Z + npm run e2e
2018-01-24T05:27:47.2861603Z + ~~~~~~~~~~~
2018-01-24T05:27:47.2862153Z  CategoryInfo :NotSpecified: (Without `from` ...t this warning.:String) [], RemoteException
2018-01-24T05:27:47.2862721Z  FullyQualifiedErrorId :NativeCommandError

当我远程进入 Azure VM 并仅运行 powershell 脚本时,它确实成功地运行了所有量角器测试,但在 VSTS 运行它时却没有。另一个问题是它不会在控制台中输出 VSTS 中通过/失败的测试。

【问题讨论】:

    标签: protractor azure-devops azure-pipelines-release-pipeline


    【解决方案1】:

    改用 PowerShell 任务试试:

    $password = ConvertTo-SecureString "[password]" -AsPlainText -Force
    $cred= New-Object System.Management.Automation.PSCredential ("[username]", $password)
    $sc = {
    $ErrorActionPreference = 'Continue'
    E:
    cd E:\dd\angularclitest
    npm run test
    }
    Invoke-Command -ComputerName [machine] -ScriptBlock $sc -credential $cred
    

    注意:用户名和密码可以存储在构建/发布变量中。

    【讨论】:

      猜你喜欢
      • 2017-05-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多