centos安装jenkins
# 安装jenkins
# 前提已安装JDK
# 去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.key
yum install jenkins
# 启动Jenkins
# 启动报错
# 修改Jenkins启动配置文件,指定java安装路径
vim /etc/init.d/jenkins
# 在candidates中第一行添加java路径,如下
candidates="
/opt/java/jdk1.8.0_51/bin/java
service jenkins start
# 在浏览器中访问 http://$IP:8080/
# 首次进入会要求输入初始密码如下图
# 初始密码在/var/lib/jenkins/secrets/initialAdminPassword
cat /var/lib/jenkins/secrets/initialAdminPassword
# This Jenkins instance appears to be offline
In my case, it has something to do with SSL. I manage to fix it by editing `/var/lib/jenkins/hudson.model.UpdateCenter.xml` and change url to use `http` instead of `https`.Restart jenkins and reload the website, it no longer shows offline.
cat /var/lib/jenkins/hudson.model.UpdateCenter.xml
vim /var/lib/jenkins/hudson.model.UpdateCenter.xml
service jenkins restart
# 选择“Install suggested plugins”安装默认的插件,下面Jenkins就会自己去下载相关的插件进行安装。
# 创建超级管理员账号
# 相关配置
# Jenkins安装目录
/var/lib/jenkins
# Jenkins配置文件地址
cat /etc/sysconfig/jenkins
# 三个比较重要的配置
JENKINS_HOME是Jenkins的主目录,Jenkins工作的目录都放在这里,Jenkins储存文件的地址,Jenkins的插件,生成的文件都在这个目录下。
JENKINS_USER是Jenkins的用户,拥有$JENKINS_HOME和/var/log/jenkins的权限。
JENKINS_PORTJENKINS_PORT是Jenkins的端口,默认端口是8080。