Jenkins:安装配置
本机安装jenkins
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-2023.key
sudo yum upgrade -y
# Add required dependencies for the jenkins package
sudo yum install java-11-openjdk -y
sudo yum install jenkins -y
sudo systemctl daemon-reload
sudo systemctl enable jenkins
sudo systemctl start jenkins
sudo systemctl status jenkins
说明
Ubuntu:
jenkins安装目录:/var/lib/jenkins
jenkins日志目录:/var/log/jenkins/jenkins.log
jenkins默认配置:/etc/default/jenkins
Centos7:
jenkins安装目录:/var/lib/jenkins
jenkins日志目录:/var/log/jenkins/jenkins.log
jenkins默认配置:/etc/sysconfig/jenkins
配置root启动(不建议)
# 设置权限
sudo chown -R root:root /var/lib/jenkins/*
# 修改配置:/etc/sysconfig/jenkins
sudo vi /etc/sysconfig/jenkins
# 把以下两个值改为root,默认是$NAME
JENKINS_USER=root
JENKINS_GROUP=root
# 重启Jenkins
sudo systemctl restart jenkins
增加Java虚拟机内存
由于 npm 编译导致jenkins报错502,需要增加Java虚拟机内存,在配置文件中,修改:
# Centos
JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Xmx1024m -XX:MaxPermSize=512m"
# 如果是ubuntu
JAVA_ARGS="-Xmx1024m" # 默认是256
配置镜像加速
访问/var/lib/jenkins,编辑hudson.model.UpdateCenter.xml文件
vim hudson.model.UpdateCenter.xml
将url的地址链接https://updates.jenkins.io/update-center.json
修改为https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json