前提:
linux安装了jdk,配置路径如:
编辑配置文件:vi /etc/profile ,文件末尾或开头,添加如下图的部分
export JAVA_HOME=/usr/local/jdk1.8.0_191
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH
export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin
export PATH=$PATH:${JAVA_PATH}
安装步骤:
一 安装jenkins
wget -O :下载并以不同的文件名保存
yum的repo中默认没有Jenkins,需要先将Jenkins存储库添加到yum repos,执行下面的命令:
wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
然后执行下面的命令:yum --import 增加资源库
rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
然后 安装Jenkins
yum install -y jenkins 默认安装最新的
启动jenkins
systemctl start jenkins.service
systemctl status jenkins.service
报错 Jenkins bash: /usr/bin/java: No such file or directory
发现是找不到jdk,修改文件:
vim /etc/init.d/jenkins
candidates="
/usr/local/jdk1.8.0_191/bin/java #此处为加入的java路径
/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
[root@localhost ~]# systemctl stop jenkins.service
Warning: jenkins.service changed on disk. Run 'systemctl daemon-reload' to reload units.
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl stop jenkins.service
[root@localhost ~]# systemctl start jenkins.service
[root@localhost ~]# systemctl status jenkins.service
● jenkins.service - LSB: Jenkins Automation Server
Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled)
Active: active (running) since Sun 2018-12-16 22:49:46 EST; 10s ago
Docs: man:systemd-sysv-generator(8)
Process: 6839 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=0/SUCCESS)
Tasks: 31
Memory: 310.1M
CGroup: /system.slice/jenkins.service
└─6858 /usr/local/jdk1.8.0_191/bin/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/j...
Dec 16 22:49:45 localhost.localdomain systemd[1]: Starting LSB: Jenkins Automation Server...
Dec 16 22:49:45 localhost.localdomain runuser[6844]: pam_unix(runuser:session): session opened for user jenkins by (uid=0)
Dec 16 22:49:46 localhost.localdomain runuser[6844]: pam_unix(runuser:session): session closed for user jenkins
Dec 16 22:49:46 localhost.localdomain systemd[1]: Started LSB: Jenkins Automation Server.
Dec 16 22:49:46 localhost.localdomain jenkins[6839]: Starting Jenkins [ OK ]
2. 把jekins的端口加入防火墙:
[root@localhost ~]# firewall-cmd --zone=public --add-port=8080/tcp --permanent
success
[root@localhost ~]# firewall-cmd --reload
success
[root@localhost ~]# firewall-cmd --zone=public --query-port=8080/tcp
yes
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl start firewalld
[root@localhost ~]# systemctl status firewalld
查看网址:http://172.16.244.131:8080/,打开就是如下图:
[root@localhost ~]# cat /var/lib/jenkins/secrets/initialAdminPassword
0651b69bb79a4d65a6d5ff6e7c9cb7e8
输入网页的密码窗口处,
选择“Install suggested plugins”安装默认的插件,下面Jenkins就会自己去下载相关的插件进行安装。
设置用户:admin/admin