【问题标题】:Teamcity newman is not recognized as an internal or external commandTeamcity newman 未被识别为内部或外部命令
【发布时间】:2020-03-07 02:19:44
【问题描述】:

我正在尝试在 Teamcity 服务器上运行邮递员测试。我按照此链接进行设置https://medium.com/@vdespa/how-to-run-postman-newman-tests-in-teamcity-9d767c7de542 虽然我已经安装了 node、npm 和 newman -g。当我从 TeamCity 命令行构建步骤运行时,它无法识别 newman 命令

正如您在步骤 2 中看到的,我只是运行命令 $ newman --version ,但它以代码 0 退出。可能是找不到 newman 的安装位置?我也试过这个 $setx /M PATH %AppData%\npm 但还是不行

任何帮助将不胜感激? @瓦伦丁·德斯帕

【问题讨论】:

  • 在 Teamcity 服务器中,我还尝试从我的测试所在的目录运行运行 newman,它显示“节点”无法识别。但是,我尝试在本地桌面上运行测试,我可以从测试目录运行测试,但这种方法在 TeamCity 中不起作用,因为它不应该是测试位置的绝对路径。但至少在我的本地桌面上,我可以 newman 从我的测试所在的绝对路径运行 C:\Users\user\source\repos\AutoTests>newman run APIAutoTests.postman_collection.json --environment ApiProtest.postman_environment.json跨度>
  • %AppData%\npm 目录中是否存在 newman 文件?
  • 是的,它确实是 C:\Users\gg\AppData\Roaming\npm 并且我有 newman windows 命令脚本和 newman powershell 脚本文件存在那里
  • 您是否在用户中检查了用于 TeamCity 服务的相同命令?
  • 运行构建(构建代理)的帐户是系统帐户,因此我无法以该用户身份登录。但是我将此命令作为构建步骤“npm prefix -g”运行,它返回以下内容: C:\Windows\System32\config\systemprofile\AppData\npm 所以知道构建代理可以访问此路径,我在该位置安装了 newman但我仍然收到“无法识别 newman”错误

标签: postman teamcity newman


【解决方案1】:

我能够通过将 newman 安装在 C:\npm 文件夹而不是任何系统文件夹下来解决此问题。同样在我这次没有将 npm Config 重置为默认值之前。我现在可以运行我的测试了。

在teamcity服务器上安装nodejs、npm和newman的详细步骤

Login to TeamCity Server

Download the Nodejs

Install Nodejs (C:\ProgramFiles\nodejs)

Open Command prompt as run as Administrator

type node -v (should return node version)

type npm - v (should return npm version)

type npm prefix -g (usually it defaults to user folder and returns
C:\Users\user1\AppData\Roaming\npm )

Note the current global prefix

Set the global prefix to by running this on cmd: npm config set prefix C:\npm

Install the needed packages by running this on cmd: npm install -g newman

Restore the prefix to the previous value by running this on cmd: npm config set prefix C:\Users\user1\AppData\Roaming\npm

Open System Environment variables

Edit environment variables and make sure this added to Path: C:\npm

Also additionally you can check under user variables for user1 Path
is set to for npm: C:\Users\user1\AppData\Roaming\npm

Now restart the windows server machine

After that, from the Teamcity web interface, restart the teamcity
server

You should have running newman on your teamcity server on cmd prompt as well as build steps

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-12-25
    • 1970-01-01
    • 2014-04-29
    • 1970-01-01
    • 1970-01-01
    • 2021-07-28
    • 2013-10-06
    相关资源
    最近更新 更多