cd /opt
mkdir Jenkins
cd Jenkins/
wget https://get.jenkins.io/redhat-stable/jenkins-2.289.1-1.1.noarch.rpm
rpm -ivh jenkins-2.289.1-1.1.noarch.rpm
【高本版的Jenkins需要Java11以上】
vim /etc/init.d/jenkins
// 修改jdk地址
/usr/local/jdk1.8.0_311/bin/java
systemctl start jenkins
systemctl status jenkins
// 外部访问时,需关闭防火墙,或开放端口
systemctl status firewalld
systemctl stop firewalld
Jenkins的默认端口是8080,若发现该端口已被占用,可以修改
vi /etc/sysconfig/jenkins
// 修改JENKINS_PORT后重启
// 浏览器输入http://ip:port,例如http://XXX:8088,自动跳转到登录页
// 获得管理员密码
cat /var/lib/jenkins/secrets/initialAdminPassword
点击Manage Jenkins》Manage Plugins
查看可安装插件
更改下载地址
// Linux执行
cd /var/lib/jenkins/updates
sed -i 's/http:\/\/updates.jenkinsci.org\/download/https:\/\/mirrors.tuna.tsinghua.edu.cn\/jenkins/g' default.json && sed -i 's/http:\/\/www.google.com/https:\/\/www.baidu.com/g' default.json
// 修改Jenkins的Update Site地址
https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json
通过访问http://ip:port/restart,例如http://XXX:8088/restart,重启Jenkins
通过安装“Chinese”插件汉化
下载war包
1)Java版本匹配Jenkins最新版本
2)Java11以下,通过官网https://get.jenkins.io/war-stable/下载历史版本war包
进入/usr/lib/jenkins目录,替换war包后重启
实际操作时,提示“Job for jenkins.service failed because the control process exited with error code.”,通过“systemctl status jenkins.service”排查原因。提示“Unable to access jarfile /usr/lib/jenkins/jenkins.war”,执行“chmod 777 /usr/lib/jenkins/jenkins.war”。
vi /var/log/jenkins/jenkins.log
rpm -e jenkins
rpm -ql jenkins
find / -iname jenkins | xargs -n 1000 rm -rf
ps -ef|grep jenkins
kill -9 XXX(pid)