centos7部署Jenkin

  • 2019 年 10 月 6 日
  • 筆記

centos7部署Jenkins

2018.08.08 14:42:26字數 381閱讀 1022

聲明:本文僅為測試插件,無腳本附件,可用作參考

1.配置安裝Jenkins

去jenkins官網https://jenkins.io/index.html下載jenkins安裝包

jenkins安裝包有兩種,一種是LTS,一種是Weekly。LTS是穩定版,Weekly每周會更新一次,目前我選擇了LTS

下載rpm包,並且安裝Jenkins rpm包

rpm -ivh jenkins-2.107.3-1.1.noarch.rpm

(1)查看Jenkins安裝包的位置

rpm -ql jenkins

(2)在下述文件中添加我的jdk目錄

vim /etc/init.d/jenkins

添加對應jdk目錄語句,其中紅色語句為需要添加

/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/local/jdk/jdk1.8.0_161/bin/java

(3)修改Jenkins端口

vim/etc/sysconfig/jenkins

JENKINS_PORT="8888"

(4)開啟8888端口防火牆

firewall-cmd –zone=public –add-port=8888/tcp –permanent

firewall-cmd –reload

(5)啟動Jenkins

service jenkins start

關閉Jenkins

service jenkins stop

重啟Jenkins

service jenkins restart

註:在啟動過程中遇到下述錯誤:

Starting jenkins (via systemctl):  Warning: jenkins.service changed on disk. Run 'systemctl daemon-reload' to reload units.

解決方案

systemctl daemon-reload

(6)在瀏覽器鍵入ip+端口打開Jenkins網頁,並出現下列圖片

http://ip:8888

(7)獲取本地管理員密碼

cat /var/lib/jenkins/secrets/initialAdminPassword

選擇安裝推薦的插件


2.構建項目

新建任務-構建一個自由風格的軟件項目

(adsbygoogle = window.adsbygoogle || []).push({});