DevOps之四 Jenkins的安装与配置
CentOS 上 Jenkins 安装
一、添加yum repos,然后安装
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/RedHat/jenkins.repo sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key sudo yum install jenkins
二、Jenkins的安装目录
cd /var/lib/jenkins/
三、jenkins配置文件
Jenkins的默认端口是8080 如果被占用可以在这里修改
vi /etc/sysconfig/jenkins
## Type: integer(0:65535) ## Default: 8080 ## ServiceRestart: jenkins # # Port Jenkins is listening on. # Set to -1 to disable # JENKINS_PORT="8081"
备注:端口最好使用1024 以上的端口,不然会报:无权限错误
四、修改Jenkins的JDK路径
vi /etc/init.d/jenkins
添加自己的jdk路径
# Search usable Java as /usr/bin/java might not point to minimal version required by Jenkins. # see http://www.nabble.com/guinea-pigs-wanted-----Hudson-RPM-for-RedHat-Linux-td25673707.html candidates=" /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-1.7.0/bin/java /usr/lib/jvm/jre-1.7.0/bin/java /usr/bin/java /usr/java/jdk1.8.0_121/bin/java /usr/java/jdk1.8.0_121/jre/bin/java "
五、启动Jenkins
systemctl start jenkins
这时候会报错误:Warning: jenkins.service changed on disk. Run 'systemctl daemon-reload' to reload units.
解决方法:
systemctl daemon-reload
六、如果服务启动查看日志
cat /var/log/jenkins/jenkins.log