从Visual Studio Team Services

时间:2018-01-24 20:47:42

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

我无法在发布定义中尝试从VSTS运行Protractor e2e测试。

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

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

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

  3. 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脚本时,它会成功运行所有Protractor测试,但是当VSTS运行它时它不会。另一个问题是它不会在控制台中输出VSTS中传递/失败的测试。

1 个答案:

答案 0 :(得分:0)

尝试使用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

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