一、安装Jenkins
1、安装Jenkins前安装jdk
yum install -y java
2、添加Jenkins库到yum库,依次执行下面命令,Jenkins将从这里下载安装
wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
yum install -y jenkins
如果不能安装就到官网下载jenkis的rmp包,官网地址(http://pkg.jenkins-ci.org/redhat-stable/)
wget http://pkg.jenkins-ci.org/redhat-stable/jenkins-2.7.3-1.1.noarch.rpm
rpm -ivh jenkins-2.7.3-1.1.noarch.rpm
3、配置jenkis的端口
vim /etc/sysconfig/jenkins
找到修改端口处(服务器端口不冲突可以不修改):
JENKINS_PORT="8080"
二、启动Jenkins
1、Jenkins命令:
# 启动Jenkins
service jenkins start
# 重启Jenkins
service jenkins restart
# 停止Jenkins
service jenkins stop
a、Jenkins将作为一个守护进程随系统启动。
b、系统会创建一个“jenkins”用户来允许这个服务,如果改变服务所有者,同时需要修改/var/log/jenkins, /var/lib/jenkins, 和/var/cache/jenkins的所有者。
c、启动的时候将从/etc/sysconfig/jenkins获取配置参数。
d、Jenkins的RPM仓库配置被加到/etc/yum.repos.d/jenkins.repo。
2、启动Jenkins错误:
[root@VM_0_2_centos /]# vim /etc/sysconfig/jenkins
[root@VM_0_2_centos /]# service jenkins start
Starting jenkins (via systemctl): Job for jenkins.service failed because the control process exited with error code. See "systemctl status jenkins.service" and "journalctl -xe" for details.
[FAILED]
[root@VM_0_2_centos /]#
修改完Jenkins端口启动Jenkins,启动失败!
上面我们说过,系统会创建一个“jenkins”用户来允许这个服务,我这里使用的用户是root,解决办法:
vim /etc/sysconfig/jenkins
修改JENKINS_USER=“jenkins” 修改为JENKINS_USER=“root”
再启动服务 service jenkins start 失败
[root@VM_0_2_centos /]# service jenkins start
Starting jenkins (via systemctl): Job for jenkins.service failed because the control process exited with error code. See "systemctl status jenkins.service" and "journalctl -xe" for details.
[FAILED]
[root@VM_0_2_centos /]#
解决办法,增加java路径(路径查看:which java):
vim /etc/rc.d/init.d/jenkins
再次启动服务,ok
[root@VM_0_2_centos bin]# vim /etc/rc.d/init.d/jenkins
[root@VM_0_2_centos bin]# service jenkins start
Starting jenkins (via systemctl): Warning: jenkins.service changed on disk. Run 'systemctl daemon-reload' to reload units.
[ OK ]
[root@VM_0_2_centos bin]#
三、在浏览器打开Jenkins
1、首次进入会要求输入初始密码如下图,初始密码在:/var/lib/jenkins/secrets/initialAdminPassword
选择 “安装推荐的插件” Jenkins会自己下载相关的插件进行安装。
安装插件
插件安装完成,创建超级管理员账号。
完成