软件准备:
jenkins-2.7.4-1.1.noarch.rpm java环境 |
安装jenkins:
[root@localhost modules]# rpm -ih jenkins-2.7.4-1.1.noarch.rpm |
jenkins 常用命令:
service jenkins start/stop/restart
chkconfig jenkins on
|
jenkins的目录结构:
/usr/lib/jenkins/jenkins.war WAR包
/etc/sysconfig/jenkins 配置文件
/var/lib/jenkins/ 默认的JENKINS_HOME目录
/var/log/jenkins/jenkins.log Jenkins日志文件
|
启动jekins:
[root@localhost jenkins]# service jenkins start Starting Jenkins bash: /usr/bin/java: 没有那个文件或目录 [失败]
|
出现此异常说明没有找到 java 目录下的 bin 目录,解压不了 jenkins.war 。
解决方案:
[root@localhost bin]# vim /etc/init.d/jenkins
# Search usable Java. We do this because various reports indicated # that /usr/bin/java may not always point to Java >= 1.6 # see http://www.nabble.com/guinea-pigs-wanted-----Hudson-RPM-for-RedHat-Linux-td25673707.html candidates=" /etc/alternatives/java /usr/lib/jvm/java-1.6.0/bin/java /usr/lib/jvm/jre-1.6.0/bin/java /usr/lib/jvm/java-1.7.0/bin/java /usr/lib/jvm/jre-1.7.0/bin/java /usr/lib/jvm/java-1.8.0/bin/java /usr/lib/jvm/jre-1.8.0/bin/java /usr/bin/java /opt/softwares/jdk1.8.0_144/bin/java " for candidate in $candidates do [ -x "$JENKINS_JAVA_CMD" ] && break JENKINS_JAVA_CMD="$candidate" done
JAVA_CMD="$JENKINS_JAVA_CMD $JENKINS_JAVA_OPTIONS -DJENKINS_HOME=$JENKINS_HOME -jar $JENKINS_WAR"
|
带色文字为我的 java 目录,脚本含义就是查找 java 目录,解压jenkins.war包。
修改jenkins端口:
vim /etc/sysconfig/jenkins
JENKINS_PORT="8888"
|
防火墙开启8888端口:
[root@localhost modules]# vim /etc/sysconfig/iptables # Firewall configuration written by system-config-firewall # Manual customization of this file is not recommended. *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 8888 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT
|
再次启动jenkins:
[root@localhost modules]# service jenkins start |
效果图:
出现此提示说明,启动成功!因为是第一次安装,所以得输入默认密码,默认密码在红框标注的位置。
查看默认密码将密码粘贴到文本框中:
[root@localhost secrets]# cat /var/lib/jenkins/secrets/initialAdminPassword 97c675381d524414ba11e61c4f4b7ef0
|
安装插件: