jenkins搭建好之后通过http://localhost:8080, 但是通过ip无法访问
解决方案
进入jenkins管理页面
系统管理 =》system =》 Jenkins Location
将Jenkins URL
设置为本地ip地址
查看Jenkins进程
ps -ef|grep jenkins
结果如下
可以看到,jenkins默认的httpListenAddress是127.0.0.1也就是本机地址,如果局域网需要访问的话需要改成0.0.0.0,修改httpPort的值就是修改端口
/opt/homebrew/opt/jenkins-lts/libexec/jenkins.war
--httpListenAddress=127.0.0.1 --httpPort=8080
按照上面给的路径进入到/opt/homebrew/opt/jenkins-lts/libexec/
, 找到配置文件homebrew.mxcl.jenkins-lts.plist
, 将里面的--httpListenAddress=127.0.0.1
改成--httpListenAddress=0.0.0.0
, 重启后再次访问就可以了
注意:home brew 安装的启动命令是(因为我安装的是jenkins-lts, 如果是jenkins, 将jenkins-lts换成jenkins即可)
Install the latest LTS version: brew install jenkins-lts
Start the Jenkins service: brew services start jenkins-lts
Restart the Jenkins service: brew services restart jenkins-lts
Update the Jenkins version: brew upgrade jenkins-lts
如果还是不行, 试试将~/Library/LaunchAgents/homebrew.mxcl.jenkins.plist的ListenAddress也改为本机ip或者0.0.0.0