一、CentOS 7.9 安裝 Jenkins 2.361.2 1 下載地址:https://www.jenkins.io/download 2 簡介 Jenkins是一個Java開發的開源持續集成工具,廣泛用於項目開發,具有自動化構建、測試和部署等功能,它的運行需要Java環境。 二、Jenkin ...
一、CentOS 7.9 安裝 Jenkins 2.361.2
1 下載地址:https://www.jenkins.io/download
2 簡介
Jenkins是一個Java開發的開源持續集成工具,廣泛用於項目開發,具有自動化構建、測試和部署等功能,它的運行需要Java環境。
二、Jenkins Redhat Packages
To use this repository, run the following command:
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
If you've previously imported the key from Jenkins, the rpm --import
will fail because you already have a key. Please ignore that and move on.
yum install fontconfig java-11-openjdk
yum install jenkins
The rpm packages were signed using this key:
pub rsa4096 2020-03-30 [SC] [expires: 2023-03-30]
62A9756BFD780C377CF24BA8FCEF32E745F2C3D5
uid Jenkins Project <[email protected]>
sub rsa4096 2020-03-30 [E] [expires: 2023-03-30]</[email protected]>
You will need to explicitly install a supported Java runtime environment (JRE), either from your distribution (as described above) or another Java vendor (e.g., Adoptium).
三、啟動
# 啟動Jenkins
systemctl start jenkins
# 設置開機啟動
systemctl enable jenkins
# 查看Jenkins狀態
systemctl status jenkins
# 關閉Jenkins
systemctl stop jenkins
在瀏覽器打開Jenkins控制面板 http://IP:8080/
如果一直瀏覽器一直是這個界面,就需要修改一下Jenkins的配置文件,然後重啟Jenkins,然後等待瀏覽器出現輸入密碼的界面表示Jenkins啟動成功
vim /var/lib/jenkins/hudson.model.UpdateCenter.xml
systemctl restart jenkins
# https://updates.jenkins.io/update-center.json
# https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json
如果不記得密碼,可以通過以下命令找回
cat /var/lib/jenkins/secrets/initialAdminPassword
四、Jenkins 插件安裝失敗
cd /var/lib/jenkins/updates
# 備份default.json
cp default.json default.json.bak
sudo sed -i 's#updates.jenkins.io/download/plugins#mirrors.tuna.tsinghua.edu.cn/jenkins/plugins#g' default.json && sudo sed -i 's#www.google.com#www.baidu.com#g' default.json
# 重啟jenkins
systemctl restart jenkins
五、配置Jenkins
進入jenkins配置文件
vim /etc/sysconfig/jenkins
JENKINS_HOME="/var/lib/jenkins" # jenkins的工作路徑
JENKINS_JAVA_CMD=""
JENKINS_USER="jenkins" # 預設的jenkins用戶是jenkins
JENKINS_PORT="8080" # 修改jenkins的預設埠
查看系統8080埠是否被占用
netstat -nlt |grep 8080
六、防火牆開啟8080埠
# 關閉防火牆
systemctl stop firewalld
# 開放3306埠命令
firewall-cmd --zone=public --add-port=8080/tcp --permanent
# 配置立即生效
firewall-cmd --reload
雲主機需配置安全組
在入方向規則,允許8080放行
七、服務卸載
# 卸載jenkins服務
rpm -e jenkins
# 檢查是否卸載成功
rpm -ql jenkins
# 徹底刪除殘留文件
find / -name jenkins | xargs rm -rf