在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初始化和配置的完整流程。