清华大学资源库下载:https://mirrors.tuna.tsinghua.edu.cn/jenkins/redhat/
(注意2.357版本之后的最低需要jdk11)
wget https://mirrors.tuna.tsinghua.edu.cn/jenkins/redhat/jenkins-2.346-1.1.noarch.rpm
rpm -ivh jenkins-2.346-1.1.noarch.rpm
自动安装完成之后:
/usr/lib/jenkins/jenkins.war WAR包
/etc/sysconfig/jenkins 配置文件
/var/lib/jenkins/ 默认的JENKINS_HOME目录
/var/log/jenkins/jenkins.log Jenkins日志文件
vi /etc/sysconfig/jenkins
改配置:
JENKINS_PORT="8084"
JENKINS_USER="root"
JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Dorg.apache.commons.jelly.tags.fmt.timeZone=Asia/Shanghai"
查看java运行时
whereis java
如果不显示/usr/bin/java则需要修改jenkins的jdk配置,修改的方式有两种:建立软连接或者修改/etc/init.d/jenkins
建立软连接,
一般使用yum install自动安装都会显示/usr/bin/java,s使用yun install 安装jdk可以参考《Centos7配置JDK》的方式一
ln -s /opt/jdk/jdk1.8.0_333/bin/java /usr/bin/java
改环境变量
vi /etc/init.d/jenkins
修改candiates,在第一行添加你的jdk实际路径
candidates="
/opt/jdk/jdk1.8.0_333/bin/java
/etc/alternatives/java
/usr/lib/jvm/java-1.8.0/bin/java
/usr/lib/jvm/jre-1.8.0/bin/java
/usr/lib/jvm/java-11.0/bin/java
/usr/lib/jvm/jre-11.0/bin/java
/usr/lib/jvm/java-11-openjdk-amd64
/usr/bin/java
"
启动
cd /etc/init.d
./jenkins start
修改默认镜像源
vi /var/lib/jenkins/hudson.model.UpdateCenter.xml
内容如下:
<?xml version='1.1' encoding='UTF-8'?>
<sites>
<site>
<id>default</id>
<url>https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json</url>
</site>
</sites>
获取访问秘钥,复制下来,接下来要验证
cat /var/lib/jenkins/secrets/initialAdminPassword