一、docker安装部署jenkins
二、通过yum命令安装Jenkins
1、检查安装环境
是否安装jdk,安装参考:Linux搭建测试环境
2、下载安装yum包
# wget https://prodjenkinsreleases.blob.core.windows.net/redhat-stable/jenkins-2.164.2-1.1.noarch.rpm
# yum -y install jenkins-2.164.2-1.1.noarch.rpm
# vim /etc/sysconfig/jenkins //自定义端口,修改下面参数项
...
JENKINS_PORT="8686"
...
#下载Jenkins 2.336版本 下载地址:https://www.jenkins.io/download/
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat/jenkins.io.key
yum install jenkins
1)yum安装后的jenkins相关文件目录位置:find / -name jenkins
2)启动jenkins,Starting Jenkins bash: /usr/bin/java: No such file or directory
# 服务方式启动jenkins
systemctl start jenkins
# 上述命令报错,提示找不到/usr/bin/java执行文件,查看本地java安装路径
which java
# 创建/usr/bin/java软连接,再次启动jenkins成功
ln -s /usr/local/tools/jdk1.8.0_161/bin/java /usr/bin/java
完成上面步骤,jenkins服务可正常启动,可通过curl命令测试连接是否可用,如下图:
3、jenkins初始化
1)输入http://ip:8686/login,访问成功
2)将/var/lib/jenkins/secrets/initialAdminPassword路径下的内容(管理员密码)复制到上图输入框中