1

I'm attempting to use Node + Gulp during a Visual Studio Online build process via a Hosted Agent.

The first step (Node Install) works correctly, however the second returns :

[command]C:\NPM\Modules\gulp.cmd --gulpfile C:\a\1\s\$(build.AgentDirectory)\Platform\gulpfile.js \Platform\gulpfile.js was unexpected at this time.

C:\a\1\s> "C:\NPM\Modules\node.exe" "C:\NPM\Modules\node_modules\gulp\bin\gulp.js" --gulpfile C:\a\1\s\$(build.AgentDirectory)\Platform\gulpfile.js

[error]Gulp failed with error: C:\NPM\Modules\gulp.cmd failed with return code: 255

I've taken a look at similar issues which highlight installing node globally and/or ensuring no spaces are within your project files. Neither applies or seems to help.

Finally here is how my paths and steps are configured :

  1. NPM Install (Working folder : $/Platform/Platform, Command : Install)
  2. Gulp (Gulp file path : $/Platform/Platform/gulpfile.js, Gulpjs location : node_modules/gulp/bin/gulp.js, Working folder blank)

Setting the Gulp file path seems mandatory since the Gulp.js is in a subdirectory within the repository. All other settings doesn't seem to help very much.

Any suggestions?

1 Answers1

0

Yes, you need to specify the gulp file with the relative path, the path could be the server path (as you said) and relative path of current working directory (cwd: C:\a\1\s), for example CoreAppDemo/src/CoreWebDemo/gulpfile.js

Based on the source code of gulp build task, you can find that it doesn’t parse build variable, so $(build.AgentDirectory) is not recognizable.

starian chen-MSFT
  • 33,174
  • 2
  • 29
  • 53
  • Thanks for the response. I've attempted to use a relative path (./Platform/Platform/gulpfile.js) however this resulted in an "gulpfile not found error" within C:\a\1\s\Platform\Platform\gulpfile.js. I'm unsure of how to resolve the agent directory to an actual path? – Tom Beckett Nov 22 '16 at 12:31
  • @TomBeckett Is result path the c:\a\1\s\Platform\glupfile.js? Go to Repository Tab of your build definition and check the Local Path and Server Path mapping (Mappings section). For example: Server Path: $/Platform, Local Path: $(build.sourcesDirectory)\, then the gulp file path is Platform/gulpfile.js. – starian chen-MSFT Nov 23 '16 at 02:39
  • I have a Local Path : $(build.sourcesDirectory)\ which is mapped to $(build.AgentDirectory). I believe this was the default. No server path mapping is found within the mapping section. – Tom Beckett Nov 23 '16 at 07:15
  • @TomBeckett the Sever Path cannot empty, so what's the value of Server Path? You can add the screenshot to this thread (edit). – starian chen-MSFT Nov 23 '16 at 07:33
  • Ah yes sorry. I've attached a screenshot to the question to help. – Tom Beckett Nov 23 '16 at 07:45
  • @TomBeckett Delete $(build.AgentDirectory) in local path, leave it empty (the source files will be download to c:\a\1\s). After that the glupfile.js path could be Platform\glupfile.js if the file is in $/NTPlatForm/Platform/glupfile.js. – starian chen-MSFT Nov 23 '16 at 07:56
  • That did it! Clearing out the local path seemed to resolve the issue (after a few gulp path tweaks). Many many thanks! – Tom Beckett Nov 23 '16 at 08:30