在Debian系統上部署Jenkins的步驟如下:
硬件與操作系統選擇:
安裝依賴與Jenkins:
sudo apt update && sudo apt install -y openjdk-11-jdk
sudo yum install -y java-11-openjdk-devel
sudo wget -O /usr/share/keyrings/jenkins-keyring.asc https://pkg.jenkins.io/debian-stable/jenkins.io.key
echo "deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian-stable binary/" | sudo tee /etc/apt/sources.list.d/jenkins.list
sudo apt update && sudo apt install -y jenkins
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
sudo yum install -y jenkins
sudo systemctl enable jenkins
sudo systemctl start jenkins
sudo systemctl status jenkins # 確認狀態為Active
防火墻與端口開放:
sudo ufw allow 8080/tcp
sudo ufw allow 50000/tcp
sudo ufw reload
http://<服務器IP>:8080
,輸入初始密碼:sudo cat /var/lib/jenkins/secrets/initialAdminPassword
。Manage Jenkins -> Plugin Manager -> Advanced
,替換 Update Site URL
為:https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json
,安裝必備插件:Pipeline、GitHub Integration、Docker、Kubernetes CLI、Credentials Binding。Manage Jenkins -> Security -> Enable security
,選擇 Logged-in users can do anything
。ssh-keygen -t rsa -b 4096 -f ~/.ssh/jenkins_github
,復制公鑰到GitHub的Deploy Keys。Manage Jenkins -> Credentials -> System -> Global credentials
,添加SSH私鑰(類型:SSH Username with private key),ID命名為 github-ssh
。demo-pipeline
。Pipeline script from SCM
,配置Git倉庫地址與憑據編輯。以上步驟涵蓋了在Debian系統上從環境準備到Jenkins初始化和配置的完整流程。