不建议使用 Docker 运行 Jenkins
# 安装 Java
apt update
apt install openjdk-11-jdk
java --version
# 安装 Jenkins
curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \
/usr/share/keyrings/jenkins-keyring.asc > /dev/null
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 > /dev/null
apt update
apt install jenkins
# 启动 Jenkins, 访问 8080 端口
systemctl start jenkins
systemctl status jenkins
# 初始密码
cat /var/lib/jenkins/secrets/initialAdminPassword
如果启动超时:
# 设置超时时间 TimeoutStartSec=1000
vi /lib/systemd/system/jenkins.service
systemctl daemon-reload