运行 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
在“构建参数”部分下。 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/