![](/style/images/good.png)
![](/style/images/bad.png)
Jenkins pipeline macOS agent 报错:cmake: command not found
source link: https://www.mycode.net.cn/language/cpp/3146.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Jenkins pipeline macOS agent 报错:cmake: command not found
在一台 macOS 的 anget 中,我们的 pipeline 脚本一直报错:cmake: command not found
,但实际系统中已经通过 brew 安装过 cmake。并且在系统中通过使用命令 cmake --version
也能显示正常版本。那是不是 cmake 所在的目录并不在 Jenkins agent 的环境变量中呢?为了验证这个问题我们在 Jenkinsfile 中增加一行打印当前环境变量信息的语句:
sh "printenv"
增加完成后运行当前 job,此时会将所有该 agent 下的环境变量信息打印出来,查看当前 PATH 的环境变量包含如下内容:
而实际我们的 cmake 文件在 /usr/local/bin
目录下,PATH 中并不包含该路径:
由此证明的确系统中安装的 cmake 并不在 Jenkins agent 的环境变量中。有两种手段可以解决该问题,一种是修改 Jenkinsfile 手动新增,另外一种是直接修改 agent 配置将 /usr/local/bin
添加到 PATH 环境变量中。前者跟 Jenkinsfile 绑定一旦更换 agent 或者 agent 环境不统一这样一个 Jenkinsfile 就不能通用了。所以我们还是要使用后者的方式,打开 agent 配置界面,在环境变量中新增如下内容:
这样这个配置就单独与这台 agent 绑定了,不会影响其他 agent 并且也不需要修改 Jenkinsfile。将当前 agent disconnect 掉,在重新运行起来就可以找到 cmake 执行文件了。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK