一、docker安装部署jenkins

参考:docker安装部署jenkins

二、通过yum命令安装Jenkins

1、检查安装环境

是否安装jdk,安装参考:Linux搭建测试环境

image.png

2、下载安装yum包

  1. # wget https://prodjenkinsreleases.blob.core.windows.net/redhat-stable/jenkins-2.164.2-1.1.noarch.rpm
  2. # yum -y install jenkins-2.164.2-1.1.noarch.rpm
  3. # vim /etc/sysconfig/jenkins //自定义端口,修改下面参数项
  4. ...
  5. JENKINS_PORT="8686"
  6. ...
  7. #下载Jenkins 2.336版本 下载地址:https://www.jenkins.io/download/
  8. sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat/jenkins.repo
  9. sudo rpm --import https://pkg.jenkins.io/redhat/jenkins.io.key
  10. yum install jenkins

1)yum安装后的jenkins相关文件目录位置:find / -name jenkins
image.png
2)启动jenkins,Starting Jenkins bash: /usr/bin/java: No such file or directory

  1. # 服务方式启动jenkins
  2. systemctl start jenkins
  3. # 上述命令报错,提示找不到/usr/bin/java执行文件,查看本地java安装路径
  4. which java
  5. # 创建/usr/bin/java软连接,再次启动jenkins成功
  6. ln -s /usr/local/tools/jdk1.8.0_161/bin/java /usr/bin/java

完成上面步骤,jenkins服务可正常启动,可通过curl命令测试连接是否可用,如下图:
image.png

3、jenkins初始化

1)输入http://ip:8686/login,访问成功
image.png
2)将/var/lib/jenkins/secrets/initialAdminPassword路径下的内容(管理员密码)复制到上图输入框中
image.png
image.png
image.png
image.png
image.png