一、下載依賴
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 jenkins
四、啟動前檢查是否已安裝jdk
java #顯示java參數即證明已安裝jdk
五、查找jenkins安裝路徑
rpm -ql jenkins

jenkins相關目錄釋義:1./usr/lib/jenkins/:jenkins安裝目錄,war包會放在這里。2./etc/sysconfig/jenkins:jenkins配置文件,“端口”,“JENKINS_HOME”等都可以在這里配置。3./var/lib/jenkins/:默認的JENKINS_HOME。4./var/log/jenkins/jenkins.log:jenkins日志文件。
六、配置jenkins
1.查找jenkins端口vim /etc/sysconfig/jenkins

2.查看其他端口占用情況netstat -ntlp

被占用端口與jenkins端口8080無沖突,即可進入下一步啟動jenkins3.啟動jenkinsjava -jar /usr/lib/jenkins/jenkins.war --httpPort=80804.修改jenkins端口若默認8080端口未被占用,可不修改若端口已被占用,則修改端口為其他端口,並將對應端口開放①端口改為8899java -jar /usr/lib/jenkins/jenkins.war --ajp13Port=-1 --httpPort=8899②啟動java -jar /usr/lib/jenkins/jenkins.war --httpPort=8899

也可使用systemctl啟動命令啟動:systemctl daemon-reloadsystemctl enable jenkinssystemctl start jenkins
5.驗證jenkins能否打開①瀏覽器輸入http://IP:Port②進入jenkins解密界面

③獲取密碼cat /var/lib/jenkins/secrets/initialAdminPassword

=>獲取密碼=>輸入密碼=>繼續=>安裝插件=>retry幾次可安裝成功=>注冊賬號 (記錄好賬號密碼)=>開始使用Jenkins
七、關於centos7 yum安裝java環境
1.查看yum源的java包

2.安裝java1.8 jdk軟件yum -y install java-1.8.0-openjdk

3.查看版本,檢測是否安裝成功java -version

