linux 安装jenkins jdk17
时间: 2023-09-28 18:10:09 浏览: 199
您好!要在Linux上安装Jenkins和JDK 17,您可以按照以下步骤进行操作:
1. 安装JDK 17:
- 在终端中运行以下命令以添加AdoptOpenJDK存储库:
```
sudo apt install apt-transport-https
wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -
echo "deb https://adoptopenjdk.jfrog.io/adoptopenjdk/deb focal main" | sudo tee /etc/apt/sources.list.d/adoptopenjdk.list
```
- 更新存储库并安装JDK 17:
```
sudo apt update
sudo apt install adoptopenjdk-17-hotspot
```
- 验证JDK安装是否成功:
```
java -version
```
- 您应该能够看到类似以下的输出,表示JDK 17已成功安装:
```
openjdk version "17" 2021-09-14
OpenJDK Runtime Environment AdoptOpenJDK-17.0.0+35 (build 17+35)
OpenJDK 64-Bit Server VM AdoptOpenJDK-17.0.0+35 (build 17+35, mixed mode, sharing)
```
2. 安装Jenkins:
- 在终端中运行以下命令以导入Jenkins存储库的GPG密钥:
```
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
```
- 添加Jenkins存储库:
```
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
```
- 更新存储库并安装Jenkins:
```
sudo apt update
sudo apt install jenkins
```
- 启动Jenkins服务:
```
sudo systemctl start jenkins
```
- 验证Jenkins服务是否正在运行:
```
sudo systemctl status jenkins
```
- 您应该能够看到类似以下的输出,表示Jenkins已成功安装并正在运行:
```
● jenkins.service - LSB: Start Jenkins at boot time
Loaded: loaded (/etc/init.d/jenkins; generated)
Active: active (running) since Wed 2021-10-20 13:01:43 UTC; 3s ago
Docs: man:systemd-sysv-generator(8)
Tasks: 2 (limit: 2282)
Memory: 270.7M
CGroup: /system.slice/jenkins.service
└─1852 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/jenkins/jenkins.war --webroot=/var/cache/jenkins/war --httpsPort=8080 --httpPort=-1 --controlPort=jenkins
Oct 20 13:01:43 ubuntu systemd[1]: Starting LSB: Start Jenkins at boot time...
Oct 20 13:01:43 ubuntu jenkins[1803]: Correct java version found
Oct 20 13:01:43 ubuntu jenkins[1803]: * Starting Jenkins Automation Server jenkins
Oct 20 13:01:43 ubuntu su[1830]: Successful su for jenkins by root
Oct 20 13:01:43 ubuntu su[1830]: + ??? root:jenkins
Oct 20 13:01:43 ubuntu su[1830]: pam_unix(su:session): session opened for user jenkins by (uid=0)
Oct 20 13:01:43 ubuntu systemd[1]: Started LSB: Start Jenkins at boot time.
```
现在您应该已经成功在Linux上安装了Jenkins和JDK 17。您可以通过在Web浏览器中访问`http://localhost:8080`来访问Jenkins的Web界面,并按照向导完成初始设置。
希望这能帮到您!如果您有任何其他问题,请随时提问。
阅读全文