TeamCity build runner not recognizing executable

后端 未结 8 1499
悲哀的现实
悲哀的现实 2020-12-25 13:12

I\'m trying to run a simple gruntfile.js as part of my build in TeamCity. However, even after installing grunt and grunt-cli as global node packages, TeamCity s

相关标签:
8条回答
  • 2020-12-25 13:49

    This was a weird and very annoying bug, but I finally found a workaround. In the %AppData%\Roaming\npm directory, there are two files: "grunt" and "grunt.cmd". "grunt" is a unix file, and "grunt.cmd" is supposed to run the grunt-cli application using node, but it doesn't. I had to create a new file called "grunt.bat" (which takes precedence over "grunt.cmd") that contains

    node "%~dp0\node_modules\grunt-cli\bin\grunt" %*
    

    Now it works. Not sure why.

    0 讨论(0)
  • 2020-12-25 13:50

    You don't need to change TeamCity account from system to local like Christoper wrote. It's simpler way:

    1.[build agent machine] Make sure you have node directory and local npm packages directory in your PATH, example:

     C:\Users\'yourUserName'\AppData\Roaming\npm;C:\Program Files\nodejs 
    1. [build agent machine] Install grunt globally: npm install grunt-cli
    2. [build step] Run cmd in your project dirctory: npm install -g grunt-cli. You can do this step only once (on your local machine) and commit file changes to repo
    3. [build step] Run cmd in your project dirctory: npm install
    4. [build step] Run grunt build as powershell script: powershell -Command "grunt build"

    In some reason build agent running on system account cant get access to C:\Users\'yourUserName'\AppData\Roaming\npm via cmd, but via powershell can.

    0 讨论(0)
提交回复
热议问题