一、部署Jenkins
#安装一个Tomcat作为中间件
#需要Java1.8以上的JDK环境
[[email protected] /]# java -version
openjdk version "1.8.0_102"
OpenJDK Runtime Environment (build 1.8.0_102-b14)
OpenJDK 64-Bit Server VM (build 25.102-b14, mixed mode)
#部署Tomcat
[[email protected] ~]# wget https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-7/v7.0.100/bin/apache-tomcat-7.0.100.tar.gz
[[email protected] ~]# tar zxf apache-tomcat-7.0.100.tar.gz
[[email protected] ~]# mv apache-tomcat-7.0.100/ /usr/local/tomcat
[[email protected] ~]# echo ‘export CATALINA_HOME=/usr/local/tomcat‘ >> /etc/profile
[[email protected] ~]# echo ‘export PATH=$CATALINA_HOME/bin:$PATH‘ >> /etc/profile
[[email protected] ~]# source /etc/profile
[[email protected] /]# vim /usr/local/tomcat/conf/server.xml # 修改tomcat端口号
<Connector port="8081" protocol="HTTP/1.1"
[[email protected] ~]# startup.sh
[[email protected] ~]# netstat -anput | grep 8081
tcp6 0 0 :::8081 :::* LISTEN 3006/java
#当将Jenkins的war包放入中间件时,它会自动去进行部署,所以我们可以通过查看日志去看到安装状态
[[email protected] /]# tail -f /usr/local/tomcat/logs/
[[email protected] ~]# wget http://mirrors.jenkins.io/war-stable/latest/jenkins.war
[[email protected] ~]# cp jenkins.war /usr/local/tomcat/webapps/ # 复制到tomcat项目目录中
#在自动部署过程中会出现一行管理员密码
[[email protected] ~]# cat /root/.jenkins/secrets/initialAdminPassword # 也可通过查看此文件来确定密码
ca281fb7866b4cc588c58a8c9d309b7d
密钥输入完成后,我们需要去安装插件,如果安装途中报红,则等他安装完其他插件,再次点击重新安装即可
————附加————
如果在安装插件的途中觉得安装忒慢,可以尝试更换他的镜像源,因为Jenkins默认使用的是国外镜像源所以会有些慢,这里我们可以更改为清华镜像源
#安装完毕Jenkins后会在root目录下建立一个隐藏目录
[[email protected] ~]# sed -i ‘s/http:\/\/www.google.com\//http:\/\/www.baidu.com\//g‘ /root/.jenkins/updates/default.json
[[email protected] ~]# sed -i ‘s#http://updates.jenkins-ci.org/download/#https://mirrors.tuna.tsinghua.edu.cn/jenkins/#g‘ /root/.jenkins/updates/default.json
[[email protected] ~]# shutdown.sh
[[email protected] ~]# startup.sh
[[email protected] ~]# tail -f /usr/local/tomcat/logs/catalina.out # 查看运行状况
#再次访问Jenkins网页,重新输入密码安装插件
————附加结束————
原文地址:https://blog.51cto.com/14227204/2480237
时间: 2024-11-09 04:56:38