安装

sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
yum install jenkins

设置

vim /etc/sysconfig/jenkins
#修改监听端口,可以是其他端口号
JENKINS_PORT="8080"

配置权限

为了不因为权限出现各种问题,这里直接使用root

#修改用户为root
vim /etc/sysconfig/jenkins

#修改配置
$JENKINS_USER="root"

#修改目录权限
chown -R root:root /var/lib/jenkins
chown -R root:root /var/cache/jenkins
chown -R root:root /var/log/jenkins
#重启服务
service jenkins restart
#查看运行情况
ps -ef | grep jenkins

常用命令

#启动
systemctl start jenkins
#停止
systemctl stop jenkins
#重启
systemctl restart jenkins
#查看状态
systemctl status jenkins

访问Jenkins

http:<ip或者域名>:8080(或其他端口号)

#执行命令查看密码:
cat /var/lib/jenkins/secrets/initialAdminPassword

修改安装镜像源

插件配置里使用https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json

修改default.json文件,将updates.jenkins-ci.org替换为mirrors.tuna.tsinghua.edu.cnwww.google.com替换为www.baidu.com

cd /var/lib/jenkins/updates/
sed -i 's#https://updates.jenkins.io/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

卸载

systemctl stop jenkins.service
rpm -e jenkins
rpm -qa | grep jenkins      # 查看是否还有jenkins依赖,有就删除
rm -rf /etc/sysconfig/jenkins.rpmsave
rm -rf /var/cache/jenkins/
rm -rf /var/lib/jenkins/
rm -rf /var/log/jenkins
rm -rf /usr/lib/jenkins

注意:需要先安装jdk

Q.E.D.


Nothing really matters to me!