CentOS 7 安裝及設定Jenkins

介紹

開源且免費的CI工具,由Java編寫的,提供了持續構建以及部署的功能,是一個自動化的server

環境

  • CentOS 7

安裝步驟

1. 添加Jenkins Repository

[root@jenkins ~]# wget --no-check-certificate  -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins.io/redhat-stable/jenkins.repo

[root@jenkins ~]# rpm --import http://pkg.jenkins.io/redhat-stable/jenkins.io.key

2. 安裝Jenkins以及Java

[root@jenkins ~]# yum install -y jenkins java-1.8.0-openjdk

3. 啟動並啟用Jenkins

[root@jenkins ~]# systemctl start jenkins*

[root@jenkins ~]# systemctl enable jenkins*

4. 在防火牆開啟80以及8080 的port

[root@jenkins ~]# firewall-cmd --zone=public --add-port=8080/tcp --permanent
success
[root@jenkins ~]# firewall-cmd --zone=public --add-service=http --permanent
success
[root@jenkins ~]# firewall-cmd --reload
success

5. 透過網頁打開Jenkins

存取URL:http://:8080

管理員密碼創建並存儲在日誌文件 /var/log/jenkins/jenkins.log 中。接著透過以下指令取得初始密碼

[root@localhost ~]# grep -A 5 password /var/log/jenkins/jenkins.log
Jenkins initial setup is required. An admin user has been created and a password generated.
Please use the following password to proceed to installation:

Admin password

This may also be found at: /var/lib/jenkins/secrets/initialAdminPassword

接著安裝插件,可直接選Install suggested plugins

接著來建立管理者帳號

到此所有設定都已完成,即可開始使用Jenkins

參考資料

How to install and Configure Jenkins on CentOS 7 and RHEL 7 (linuxtechi.com)