ubuntu18.04安装jenkins
时间: 2023-10-14 12:19:51 浏览: 141
1. 首先,需要安装Java。在终端中输入以下命令安装Java:
```
sudo apt update
sudo apt install default-jdk
```
2. 然后,下载Jenkins的APT存储库密钥并添加到系统中:
```
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
```
3. 添加Jenkins的APT存储库:
```
sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
```
4. 更新APT缓存并安装Jenkins:
```
sudo apt update
sudo apt install jenkins
```
5. 启动Jenkins服务:
```
sudo systemctl start jenkins
```
6. 检查Jenkins服务状态:
```
sudo systemctl status jenkins
```
如果服务正常运行,输出应该类似于以下内容:
```
● jenkins.service - LSB: Start Jenkins at boot time
Loaded: loaded (/etc/init.d/jenkins; generated)
Active: active (exited) since Mon 2019-08-26 16:59:47 IST; 1min 42s ago
Docs: man:systemd-sysv-generator(8)
Process: 2231 ExecStart=/etc/init.d/jenkins start (code=exited, status=0/SUCCESS)
Aug 26 16:59:45 ubuntu systemd[1]: Starting LSB: Start Jenkins at boot time...
Aug 26 16:59:46 ubuntu jenkins[2231]: Correct java version found
Aug 26 16:59:46 ubuntu jenkins[2231]: * Starting Jenkins Automation Server jenkins
Aug 26 16:59:46 ubuntu su[2272]: Successful su for jenkins by root
Aug 26 16:59:46 ubuntu su[2272]: + ??? root:jenkins
Aug 26 16:59:46 ubuntu su[2272]: pam_unix(su:session): session opened for user jenkins by (uid=0)
Aug 26 16:59:47 ubuntu jenkins[2231]: ...done.
Aug 26 16:59:47 ubuntu systemd[1]: Started LSB: Start Jenkins at boot time.
```
7. 配置防火墙以允许Jenkins流量:
```
sudo ufw allow 8080/tcp
```
8. 现在,可以通过在Web浏览器中输入“http://your_server_ip:8080”来访问Jenkins。输入管理员密码,该密码可以在以下位置找到:
```
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
```
9. 安装完成后,可以在Jenkins中安装所需的插件和配置Jenkins以满足特定的需求。
阅读全文