---
# System prepended metadata

title: JENKINS 建置操作手冊
tags: [服務建置安裝手冊]

---

# JENKINS 建置操作手冊

###### tags: `服務建置安裝手冊`

## 下載與安裝
1. 更新已安裝套件
```bash=+
# sudo yum update –y
```
2. 下載 Jenkins repo 檔
```bash=+
# sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
```
3. 匯入 GPG-KEY 密鑰文件
```bash=+
# sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
```
4. 版本升級
```bash=+
# sudo yum upgrade
```
5. 安裝 java
```bash=+
# sudo amazon-linux-extras install java-openjdk11 -y
```
6. 安裝 jenkins
```bash=+
# sudo yum install jenkins -y
```
7. 開啟 jenkins 服務並查看狀態
```bash=+
# sudo systemctl enable jenkins
# sudo systemctl start jenkins
# sudo systemctl status jenkins
```
## 打開瀏覽器連線
8. `http://IP:8080`
9. 取得 admin 密碼指令 
```bash=+
# sudo cat /var/lib/jenkins/secrets/initialAdminPassword
    c7e9819cda674f76bb138e3ad6c4941f
```
![](https://i.imgur.com/78nzCjL.png)
10. 建立專案
![](https://i.imgur.com/XgEauA1.png)

### 補 :
* 改 80 port 不行，改 8888 port 可以
1. 官方文件修改默認工作區目錄，更改後沒反應
* https://www.cnblogs.com/zjfjava/p/16084023.html
```bash=+
# sudo vim /etc/sysconfig/jenkins
    JENKINS_PORT="8888"
# sudo systemctl restart jenkins
```
2. 網路上解法
```bash=+
# sudo vim /lib/systemd/system/jenkins.service
    Environment="JENKINS_PORT=8888"
# sudo systemctl daemon-reload
# sudo systemctl restart jenkins
```
![](https://i.imgur.com/Wtqg725.png)


