ubuntu安装jenkins(各种坑总结)

前提准备:安装jdk
在线安装jenkins:https://pkg.jenkins.io/debian-stable/
1、将存储库密钥添加到系统
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
添加密钥后,系统将返回OK
2、将Debian包存储库地址附加到服务器的sources.list :
echo deb http://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list
ps:协议是http
3、运行update ,以便apt-get将使用新的存储库
sudo apt-get update
执行时报错:
http://us.archive.ubuntu.com/ubuntu bionic InRelease Could not resolve ‘us.archive.ubuntu.com’
解决方案:使用163源mirrors.163.com或阿里源mirrors.cloud.aliyuncs.com,
修改/etc/apt/sources.list文件
再次执行还是报错
解决方案:
修改 resolv.conf 文件中的 nameserver 中的值
sudo vim /etc/resolv.conf
添加nameserver 8.8.8.8 ,保存后重启,/etc/init.d/networking restart
再次执行sudo apt-get update,成功
4、安装jenkins
sudo apt-get install jenkins
启动服务时报错:
Job for jenkins.service failed because the control process exited with error code.
See “systemctl status jenkins.service” and “journalctl -xe” for details.
意思是是没有找到java文件,需要自己把java文件地址复制过去
解决方案:
vi vi /etc/init.d/jenkins
添加java环境变量保存
在这里插入图片描述
启动jenkins,sudo service jenkins restart
异常提示:
The unit file, source configuration file or drop-ins of jenkins.service changed on disk. Run ‘systemctl daemon-reload’ to reload units.
解决方案:
systemctl daemon-reload
启动jenkins
systemctl restart jenkins
结束
浏览器访问:http://ip:8080/jenkins/login?from=%2Fjenkins%2F
访问页面显示404,tomcat可以正常访问
解决:找到jenkins目录,将jenkins.war 放到tomcat的webapps目录下


版权声明:本文为haojy521原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。