79300680

Date: 2024-12-22 08:26:50
Score: 2
Natty:
Report link

Running the gulp command with locally installed gulp on Azure Pipelines using a self-hosted agent

I encountered the same issue while using Azure Pipelines with a self hosted agent. My pipeline installed gulp v4.0.2 locally for my project. I didn't want to install gulp globally for the same reason as mentioned by @RSW.

Ref: @RSW's comment under this answer for a similar issue

Not good solution for my case. I am using azure pipelines with self hosted agent. I don't want to install the gulp globally because different projects may require different versions of gulp. What options do I have? Please help

Solution

Instead of using Azure Pipelines' built-in gulp task, such as:

- task: gulp@1
  displayName: 'Run gulp tasks'

...which, in my case, generated the following error: ##[error]Unhandled: Unable to locate executable file: 'gulp'.

You can use this alternative approach:

- script: './node_modules/.bin/gulp'
  displayName: 'Run gulp tasks'
Additional info about script:

Remember that not all build activities map to a built-in task. For example, there's no built-in task that runs the node-Sass utility, or writes build info to a text file. To run general system commands, you use the CmdLine@2 or script task. The pipeline uses the script task because it's a common shortcut for CmdLine@2.

Ref: Microsoft Learn: Exercise - Create the pipeline

Additional info about local node packages installed on Azure self-hosted agents

The local Node package folder (node_module/), where your self-hosted agent installs packages for a pipeline run, is likely located at a path like: C:\agents\_work\2\s\node_modules\ (on my Windows machine). Here, C:\agents\_work\2\s\ contains the project files for that specific pipeline run. *Note that this path may vary between different pipeline runs.

Reasons:
  • Whitelisted phrase (-1.5): You can use
  • RegEx Blacklisted phrase (3): Please help
  • Long answer (-1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • User mentioned (1): @RSW
  • Low reputation (0.5):
Posted by: Sean Lin