#Jenkins安装 for linux
安装Jenkins
最小硬件要求
- 256 MB of RAM
- 1 GB of drive space (although 10 GB is a recommended
minimum if running Jenkins as a Docker container)
推荐最小配置
- 4 GB+ of RAM
- 50 GB+ of drive space
LTS(Long Term Support)版本
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 upgrade
# Add required dependencies for the jenkins package
sudo yum install java-11-openjdk
sudo yum install jenkins
sudo systemctl daemon-reload
jenkins开机自启动
sudo systemctl enable jenkins
启动jenkins
sudo systemctl start jenkins
查看jenkins状态
sudo systemctl status jenkins
如果一切正常,就会如下显示
Loaded: loaded (/lib/systemd/system/jenkins.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2018-11-13 16:19:01 +03; 4min 57s ago
...
如果开启了防火墙,开启端口命令
YOURPORT=8080
PERM="--permanent"
SERV="$PERM --service=jenkins"
firewall-cmd $PERM --new-service=jenkins
firewall-cmd $SERV --set-short="Jenkins ports"
firewall-cmd $SERV --set-description="Jenkins port exceptions"
firewall-cmd $SERV --add-port=$YOURPORT/tcp
firewall-cmd $PERM --add-service=jenkins
firewall-cmd --zone=public --add-service=http --permanent
firewall-cmd --reload
安装之后向导
解锁Jenkins
登录网页 http://localhost:8080
通过命令 sudo cat /var/lib/jenkins/secrets/initialAdminPassword 查看密码,随机产生的。
自定义Jenkins插件
有2个选项:
Install suggested plugins : 安装推荐的插件集,基于使用最多的用户案例。
Select plugins to install : 选中自己想要安装的插件。当你第一次使用插件,建议使用默认插件。
管理员用户
当Create First Admin User页面出现,指定管理员用户,点击Save and Finish
当Jenkins is ready页面出现,点击Start using Jenkins
注意:
页面可能显示Jenkins is almost ready!
如果页面一分钟内没有自动刷新,手工刷新浏览器。
官方文档
https://www.jenkins.io/doc/book/installing/linux/#creating-the-first-administrator-user