CentOS7中Jenkins安装

官网地址

https://pkg.jenkins.io/redhat-stable/

官网里有命令的详情,按照说明把命令行都执行完即可

  sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
  sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
  yum install epel-release # repository that provides 'daemonize'
  yum install java-11-openjdk-devel
  yum install jenkins

遇到问题

在执行sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo时,会报错:ERROR: cannot verify pjreddie.com’s certificate, Unable to locally verify the issuer’s authority.To connect to pjreddie.com insecurely, use `–no-check-certificate’.
无法建立 SSL 连接。(这里报错是因为总是要先检查网站证书,而这样大多数时候会报错,这个时候加上–no-check-certificate就可以解决问题了)
把–no-check-certificate加在命令上

  sudo wget -O /etc/yum.repos.d/jenkins.repo --no-check-certificate https://pkg.jenkins.io/redhat-stable/jenkins.repo

查看jenkins安装路径

rpm -ql jenkins

结果如下:

/etc/init.d/jenkins
/etc/logrotate.d/jenkins
/etc/sysconfig/jenkins
/usr/lib/jenkins
/usr/lib/jenkins/jenkins.war
/usr/sbin/rcjenkins
/var/cache/jenkins
/var/lib/jenkins
/var/log/jenkins

相关目录说明:
/usr/lib/jenkins:jenkins安装目录,war包会放在这里。
/etc/sysconfig/jenkins:jenkins配置文件,“端口”,“JENKINS_HOME”等都可以在这里配置。
/var/lib/jenkins:默认的JENKINS_HOME。
/var/log/jenkins:jenkins日志文件。

启动jenkins

jenkins的默认商品是8080

java -jar /usr/lib/jenkins/jenkins.war --httpPort=8080

若要修改端口

// 端口改为8899
java -jar /usr/lib/jenkins/jenkins.war --ajp13Port=-1 --httpPort=8899
// 启动
java -jar /usr/lib/jenkins/jenkins.war --httpPort=8899

浏览器访问

输入http://ip:port 即可访问,第一次打开时界面一直停在
Please wait while Jenkins is getting ready to work
提示中,网上说要修改镜像仓库地址
打开jenkins的工作目录 /root/.jenkins
打开文件hudson.model.UpdateCenter.xml
把url的内容改成https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json
保存退出,重新启动jenkins

安装完成

你可能感兴趣的:(java,jenkins,centos,运维)