Azure Pipeline:无法找到可执行文件:“gulp”。在任务 Gulp@1

问题描述 投票:0回答:1

我正在尝试创建一个运行自定义 gulp 命令的 CI 构建,但管道在任务 Gulp@1 上遇到问题。我事先运行了一个 NPM 安装命令,该命令应该包含 gulp CLI 依赖项。

这是 Azure 管道返回的错误:

Starting: gulp
==============================================================================
Task         : gulp
Description  : Run the gulp Node.js streaming task-based build system
Version      : 1.231.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/gulp
==============================================================================
##[error]Unhandled: Unable to locate executable file: 'gulp'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.
##[error]Error: Unable to locate executable file: 'gulp'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.
    at Object._which [as which] (D:\agent_A\_work\_tasks\gulp_b82cfbe4-34f9-40f5-889e-c8842ca9dd9d\1.231.0\node_modules\azure-pipelines-task-lib\internal.js:323:23)
    at Object.<anonymous> (D:\agent_A\_work\_tasks\gulp_b82cfbe4-34f9-40f5-889e-c8842ca9dd9d\1.231.0\gulptask.js:29:19)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47
Finishing: gulp

这是我在构建中运行的以下任务:

steps:
# Authenticate NuGet feeds to use this org's artifacts
- task: NuGetAuthenticate@0
  displayName: 'Authenticate Nuget Feeds'

# Restore Nuget Tool Installer
- task: NuGetToolInstaller@1
  displayName: NuGet Tool Installer
  inputs:
    versionSpec: '6.x'

# Restore Nuget Packages with Feed
- task: NuGetCommand@2
  displayName: Restore Nuget Packages with Feed
  inputs:
    command: 'restore'
    restoreSolution: '$(solution)'
    feedsToUse: 'select'
    vstsFeed: 'feed'
    
- task: Npm@1
  displayName: 'npm install'
  inputs:
    command: install
    workingDir: '$(Build.SourcesDirectory)'
    verbose: false

- task: Gulp@1
  inputs:
    workingDir: '$(Build.SourcesDirectory)'
    gulpFile: 'gulpfile.js'
    targets: 'proj:publish'
    displayName: 'Build Proj'

注意:在本地构建项目确实有效。

azure-devops continuous-integration gulp azure-pipelines
1个回答
0
投票

好吧,我发现了一些奇怪的方法。我刚刚添加了一个单独的任务来全局安装 gulp CLI,并且解决了这个问题。

- task: Npm@1
  displayName: 'Install Gulp CLI Globally'
  inputs:
    command: custom
    customCommand: 'install -g gulp-cli'
    workingDir: '$(Build.SourcesDirectory)'
    verbose: false

我认为我的项目的设置方式以及软件包的安装方式存在问题。它在本地工作的原因是我已经在本地安装了 Gulp CLI NPM 包。

© www.soinside.com 2019 - 2024. All rights reserved.