一.环境准备
安装 JDK 1.8
1 export JAVA_HOME=/usr/local/jdk1.8 2 export JRE_HOME=${JAVA_HOME}/jre 3 export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib 4 export PATH=${JAVA_HOME}/bin:$PATH
服务器 centos7 一台
二.安装jenkins
1.配置官网yum原比较慢
1 sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat/jenkins.repo 2 sudo rpm --import https://pkg.jenkins.io/redhat/jenkins.io.key
2.下载安装
1 yum install jenkins -y
可以下载国内镜像包来安装
wget https://mirrors.tuna.tsinghua.edu.cn/jenkins/redhat-stable/jenkins-2.222.3-1.1.noarch.rpm
yum install jenkins-2.222.3-1.1.noarch.rpm -y
3.修改配置文件
我这里只修改了 jenkins 家目录 端口号 和启动用户
[root@iZbp1ixd8nayjcg18ioq1fZ mnt]# cat /etc/sysconfig/jenkins |grep -v ^# |grep -v "^$" JENKINS_HOME="/opt/jenkins" JENKINS_JAVA_CMD="" JENKINS_USER="root" JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true" JENKINS_PORT="8080" JENKINS_LISTEN_ADDRESS="" JENKINS_HTTPS_PORT="" JENKINS_HTTPS_KEYSTORE="" JENKINS_HTTPS_KEYSTORE_PASSWORD="" JENKINS_HTTPS_LISTEN_ADDRESS="" JENKINS_HTTP2_PORT="" JENKINS_HTTP2_LISTEN_ADDRESS="" JENKINS_DEBUG_LEVEL="5" JENKINS_ENABLE_ACCESS_LOG="no" JENKINS_HANDLER_MAX="100" JENKINS_HANDLER_IDLE="20" JENKINS_EXTRA_LIB_FOLDER="" JENKINS_ARGS=""
4.启动
1 systemctl start jenkins.service
5.查看状态
1 systemctl status jenkins.service
三.登录配置
1.访问浏览器: http://localhost:8080/ 需要解锁jenkins
2.在提示的目录里获取秘钥
cat /var/lib/jenkins/secrets/initialAdminPassword
3.选择推荐安装的组件 等待安装完成 即可
应网络问题 安装插件报错
修改默认进项源地址
vim /var/lib/jenkins/hudson.model.UpdateCenter.xml url改为 https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json
重启jenkins