您好,登錄后才能下訂單哦!
本文主要給大家介紹了關于在centos 7安裝Jenkins的相關內容,分享出來供大家參考學習,話不多說,來一起看看詳細的介紹:
安裝
添加yum repos,然后安裝
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key sudo yum install jenkins
如果沒有java的話要安裝java
sudo yum install java
啟動和停止
sudo service jenkins start/stop/restart sudo chkconfig jenkins on
jenkins的默認設置
•Jenkins會隨系統啟動而啟動。詳情參照 /etc/init.d/jenkins
•Jenkins會創建一個用戶叫做 jenkins , 如果你修改了user,則要修修改所屬者: /var/log/jenkins , /var/lib/jenkins , /var/cache/jenkins
•如果遇到問題,查看日志 /var/log/jenkins/jenkins.log
•配置文件 /etc/sysconfig/jenkins
•默認啟用8080
打開和關閉防火墻
firewall-cmd --zone=public --add-port=8080/tcp --permanent firewall-cmd --zone=public --add-service=http --permanent firewall-cmd --reload
firewall-cmd --list-all
關于centos上的java
Jenkins不支持在centos的默認的jdk上工作。如果如下所示,則需要remove:
java -version java version "1.5.0" gij (GNU libgcj) version 4.4.6 20110731 (Red Hat 4.4.6-3)
為了正確使用Jenkins:
yum remove java
然后可以安裝openjdk
yum install java-1.7.0-openjdk
正確如下:
java -version java version "1.7.0_79" OpenJDK Runtime Environment (rhel-2.5.5.1.el6_6-x86_64 u79-b14) OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)
配置端口
修改 /etc/sysconfig/jenkins :
JENKINS_PORT="8080"
配置java路徑
直接啟動:
sudo service jenkins start
但是發現啟動失敗,于是需要配置java位置:
vi /etc/init.d/jenkins
在啟動加入本機的java:
[root@iZ94xvn71eeZ ~]# vim /etc/init.d/jenkins # Set up environment accordingly to the configuration settings [ -n "$JENKINS_HOME" ] || { echo "JENKINS_HOME not configured in $JENKINS_CONFIG"; if [ "$1" = "stop" ]; then exit 0; else exit 6; fi; } [ -d "$JENKINS_HOME" ] || { echo "JENKINS_HOME directory does not exist: $JENKINS_HOME"; if [ "$1" = "stop" ]; then exit 0; else exit 1; fi; } # Search usable Java as /usr/bin/java might not point to minimal version required by Jenkins. # see http://www.nabble.com/guinea-pigs-wanted-----Hudson-RPM-for-RedHat-Linux-td25673707.html candidates=" /etc/alternatives/java /usr/lib/jvm/java-1.8.0/bin/java /usr/lib/jvm/jre-1.8.0/bin/java /usr/lib/jvm/java-1.7.0/bin/java /usr/lib/jvm/jre-1.7.0/bin/java /usr/bin/java /usr/java/jdk1.7.0_80/bin/java "
上述最后一行是我添加的。
重啟,可以正常運行了。
--------------------------------------------------------------------------------
啟動
瀏覽器輸入ip和端口訪問,第一個頁面是正在啟動,啟動結束后會讓輸入一串密碼,然后進入插件安裝界面,選擇默認,這時候會報錯:
An error occurred during installation: Forbidden
解決辦法:
I "fixed it" by restarting Jenkins http://localhost:8080/restart 。即重啟就可以繼續了。
總結
以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作能帶來一定的幫助,如果有疑問大家可以留言交流,謝謝大家對億速云的支持。
參考
•https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Red+Hat+distributions
•http://www.cnblogs.com/tjpanda88/p/4306147.html
•http://stackoverflow.com/questions/37358775/jenkins-2-5-installation-error-an-error-occurred-during-installation-forbidden
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。