curl 未被识别为从 Teamcity 命令行脚本运行的内部或外部命令

标签 curl teamcity

运行 Teamcity 命令行脚本时,curl 未被识别为内部或外部命令。 Curl 安装在本地并且在命令提示符下工作正常。

构建日志结果:

[20:05:35]Step 2/2: Command Line
[20:05:35][Step 2/2] Starting: C:\BuildAgent\temp\agentTmp\custom_script7047202395618427524.cmd
[20:05:35][Step 2/2] in directory: C:\BuildAgent\work\376652cbd18bb804
[20:05:35][Step 2/2] 'curl' is not recognized as an internal or external command,
[20:05:35][Step 2/2] operable program or batch file.
[20:05:35][Step 2/2] Process exited with code 1
[20:05:35][Step 2/2] Step Command Line failed

curl 命令
curl -v --request PUT %teamcity.serverUrl%/httpAuth/app/rest/builds/id:%teamcity.build.id%/pin 
-u    admin:admin

最佳答案

扩展其他答案,您确实需要告诉 TeamCity curl 在哪里。

但是,您可以通过 TeamCity 通过将 curl 的路径附加到您的 env.Path 变量来完成此操作,并且这样做的好处是您不必更改 PATH每个构建代理上的变量。

  • 在您的构建配置中,添加 env.Path在“构建参数”部分下。
  • 对于值,需要指定 curl 的路径并保留现有值;就像是:
    c:\path\to\dirWithCurl;%env.Path%
  • 如果您想证明它有效,请添加测试构建步骤;只需执行以下操作并查看结果:
    echo %env.Path%curl --help

  • 我最近探索了 TeamCity 如何处理附加值……见 this answer有关太多信息和 MySql 示例。看看编辑#2,但你需要的基础知识在上面。

    关于curl 未被识别为从 Teamcity 命令行脚本运行的内部或外部命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20077101/

    相关文章:

    visual-studio-2015 - Nuget 包源 404 未找到

    php - 发送原始字节缓冲区后

    teamcity - 如何将工件从 Teamcity 复制到另一台服务器?

    php - HTTP 错误 411,请求必须分块或具有内容长度

    batch-file - 使用来自bat文件的curl http post发送多个文件

    git - 如果存在针对该 SHA1 的构建,则阻止 TeamCity 构建快进 merge 到 master

    .net-4.0 - MSTest 似乎无缘无故挂起

    git - 如何从 TFS 获取类似 git 的统计信息

    curl - 如何在 Postman 中使用 GitHub API

    bash - 如何在文件中使用 curl 命令数据?