0
votes

I have a build pipeline in VSTS that works, which contains the following steps

  1. .NET Core Restore
  2. .NET Core Build
  3. .NET Core Test
  4. Publish Test Results
  5. .Net Core Publish

Now I want to add a couple of additional steps to run the npm (Angular) tests. I have a package.json that defines all of the typical commands, including test and test-single-run. It has references to jasmine-core, karma, etc. I can post full files if someone wants to see them. From the command line on my machine I can run the npm run test-single-run command and it works and executes the tests as expected.

I added 3 steps to the build pipeline above after step 4, 2 npm steps and another Publish Test Results (don't know if/how this works with 2 different sources, but that is not my problem right now).

The first npm step runs the command install and has the Working folder with package.json as src/Cranalytics.
The second npm step runs custom with the command line arguments of run test-single-run and also has the same Working folder specified.

The first npm command runs without any errors and I can see it pull down a bunch of stuff. The second one errors with the following:

    C:\Windows\system32\cmd.exe /D /S /C ""C:\Program Files\nodejs\npm.cmd" run test-single-run"  
    > [email protected] test-single-run d:\a\1\s\src\Cranalytics
    > karma start wwwroot/karma.conf.js --single-run
    [33m07 07 2017 15:13:06.270:WARN [watcher]: [39mPattern "d:/a/1/s/src/Cranalytics/wwwroot/lib/ngInfiniteScroll/build/ng-infinite-scroll.min.js" does not match any file.
    [32m07 07 2017 15:13:06.759:INFO [karma]: [39mKarma v1.7.0 server started at http://0.0.0.0:9876/
    [32m07 07 2017 15:13:06.760:INFO [launcher]: [39mLaunching browser Chrome with unlimited concurrency
    [32m07 07 2017 15:13:06.769:INFO [launcher]: [39mStarting browser Chrome
    [33m07 07 2017 15:14:06.773:WARN [launcher]: [39mChrome have not captured in 60000 ms, killing.
    [33m07 07 2017 15:14:08.777:WARN [launcher]: [39mChrome was not killed in 2000 ms, sending SIGKILL.
    [33m07 07 2017 15:14:10.778:WARN [launcher]: [39mChrome was not killed by SIGKILL in 2000 ms, continuing.
    npm ERR! Windows_NT 10.0.14393
    npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "test-single-run"
    npm ERR! node v6.10.0
    npm ERR! npm v3.10.10
    npm ERR! code ELIFECYCLE
    npm ERR! [email protected] test-single-run: `karma start wwwroot/karma.conf.js --single-run`
    npm ERR! Exit status 1
    npm ERR! 
    npm ERR! Failed at the [email protected] test-single-run script 'karma start wwwroot/karma.conf.js --single-run'.
    npm ERR! Make sure you have the latest version of node.js and npm installed.
    npm ERR! If you do, this is most likely a problem with the Cranalytics package,
    npm ERR! not with npm itself.
    npm ERR! Tell the author that this fails on your system:
    npm ERR! karma start wwwroot/karma.conf.js --single-run
    npm ERR! You can get information on how to open an issue for this project with:
    npm ERR! npm bugs Cranalytics
    npm ERR! Or if that isn't available, you can get their info via:
    npm ERR! npm owner ls Cranalytics
    npm ERR! There is likely additional logging output above.
    npm ERR! Please include the following file with any support request:
    npm ERR! d:\a\1\s\src\Cranalytics\npm-debug.log
    Found npm debug log, make sure the path matches with the one in npm's output: d:\a\1\s\src\Cranalytics\npm-debug.log
    0 info it worked if it ends with ok
    1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
    1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
    1 verbose cli 'run',
    1 verbose cli 'test-single-run' ]
    2 info using [email protected]
    3 info using [email protected]
    4 verbose run-script [ 'pretest-single-run',
    4 verbose run-script 'test-single-run',
    4 verbose run-script 'posttest-single-run' ]
    5 info lifecycle [email protected]~pretest-single-run: [email protected]
    6 silly lifecycle [email protected]~pretest-single-run: no script for pretest-single-run, continuing
    7 info lifecycle [email protected]~test-single-run: [email protected]
    8 verbose lifecycle [email protected]~test-single-run: unsafe-perm in lifecycle true
    9 verbose lifecycle [email protected]~test-single-run: PATH: C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;d:\a\1\s\src\Cranalytics\node_modules\.bin;C:\LR\mms\Services\Mms\Provisioner\TaskAgent\agents\2.119.1\externals\git\cmd;C:\Program Files\Microsoft
     MPI\Bin\;C:\Program Files (x86)\Python36-32\Scripts\;C:\Program Files (x86)\Python36-32\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program
     Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Xoreax\IncrediBuild;C:\Program Files (x86)\GtkSharp\2.12\bin;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Program
Files\nodejs\;C:\Users\VssAdministrator\AppData\Local\Microsoft\WindowsApps;;C:\Program Files\Docker;C:\NPM\Modules;;C:\Program Files\Git LFS;C:\Program Files\CMake\bin;C:\java\ant\apache-ant-1.9.7\bin;C:\java\mav...
    10 verbose lifecycle [email protected]~test-single-run: CWD: d:\a\1\s\src\Cranalytics
    11 silly lifecycle [email protected]~test-single-run: Args: [ '/d /s /c', 'karma start wwwroot/karma.conf.js --single-run' ]
    12 silly lifecycle [email protected]~test-single-run: Returned: code: 1 signal: null
    13 info lifecycle [email protected]~test-single-run: Failed to exec test-single-run script
    14 verbose stack Error: [email protected] test-single-run: `karma start wwwroot/karma.conf.js --single-run`
    14 verbose stack Exit status 1
    14 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:255:16)
    14 verbose stack at emitTwo (events.js:106:13)
    14 verbose stack at EventEmitter.emit (events.js:191:7)
    14 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:40:14)
    14 verbose stack at emitTwo (events.js:106:13)
    14 verbose stack at ChildProcess.emit (events.js:191:7)
    14 verbose stack at maybeClose (internal/child_process.js:877:16)
    14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
    15 verbose pkgid [email protected]
    16 verbose cwd d:\a\1\s\src\Cranalytics
    17 error Windows_NT 10.0.14393
    18 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "test-single-run"
    19 error node v6.10.0
    20 error npm v3.10.10
    21 error code ELIFECYCLE
    22 error [email protected] test-single-run: `karma start wwwroot/karma.conf.js --single-run`
    22 error Exit status 1
    23 error Failed at the [email protected] test-single-run script 'karma start wwwroot/karma.conf.js --single-run'.
    23 error Make sure you have the latest version of node.js and npm installed.
    23 error If you do, this is most likely a problem with the Cranalytics package,
    23 error not with npm itself.
    23 error Tell the author that this fails on your system:
    23 error karma start wwwroot/karma.conf.js --single-run
    23 error You can get information on how to open an issue for this project with:
    23 error npm bugs Cranalytics
    23 error Or if that isn't available, you can get their info via:
    23 error npm owner ls Cranalytics
    23 error There is likely additional logging output above.
    24 verbose exit [ 1, true ]

    Error: C:\Program Files\nodejs\npm.cmd failed with return code: 1

After switching it to run on a Local Agent that has VS2017 installed on it I get the following errors in the Restore step

2017-07-12T13:21:01.1976623Z [command]C:\dbagent\bin\dotnet.exe restore C:\dbagent\_work\2\s\Cranalytics.Tests\Cranalytics.Tests.csproj
2017-07-12T13:21:01.2757797Z ##[error]Unable to process command '##vso[task.complete ]Dotnet command failed with non-zero exit code: 2147516564.' successfully. Please reference documentation (http://go.microsoft.com/fwlink/?LinkId=817296)
2017-07-12T13:21:01.2757797Z ##[error]Command doesn't have valid result value.
2017-07-12T13:21:01.3695338Z [command]C:\dbagent\bin\dotnet.exe restore C:\dbagent\_work\2\s\src\Cranalytics\Cranalytics.csproj
2017-07-12T13:21:01.3695338Z ##[error]Unable to process command '##vso[task.complete ]Dotnet command failed with non-zero exit code: 2147516564.' successfully. Please reference documentation (http://go.microsoft.com/fwlink/?LinkId=817296)
2017-07-12T13:21:01.3695338Z ##[error]Command doesn't have valid result value.

System Path: %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;%USERPROFILE%.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Git\cmd;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files\dotnet\

1

1 Answers

0
votes

You can’t run karma jasmine test on Hosted agent. You need to setup a private build agent.

Refer to this article to set up a private build agent, it’s easy: Deploy an agent on Windows