1、安装java环境
sudo apt-get isntall openjdk-11-jdk
验证
qiang@09230:~$ java -version
openjdk version "11.0.15" 2022-04-19
OpenJDK Runtime Environment (build 11.0.15+10-Ubuntu-0ubuntu0.20.04.1)
OpenJDK 64-Bit Server VM (build 11.0.15+10-Ubuntu-0ubuntu0.20.04.1, mixed mode, sharing)
drc@iZwz91oq31508figapkas0Z:~$
2、安装Jenkins
2.1Jenkins 的 Debian 软件包存储库,用于自动安装和升级。要使用此存储库,首先将密钥添加到您的系统
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
2.2、添加一个 Jenkins apt 存储库条目
在/etc/apt/sources.list中添加deb https://pkg.jenkins.io/debian-stable binary/
sudo vim /etc/apt/sources.list
2.3、更新你的本地包索引
sudo apt-get update
如果发现如下错误,通过安装一个包解决
sudo apt install ca-certificates
Hit:73 http://ppa.launchpad.net/mosquitto-dev/mosquitto-ppa/ubuntu focal InRelease
Ign:72 https://pkg.jenkins.io/debian-stable binary/ InRelease
Err:74 https://pkg.jenkins.io/debian-stable binary/ Release
Certificate verification failed: The certificate is NOT trusted. The certificate chain uses expired certificate. Could not handshake: Error in the certificate verification. [IP: 151.101.110.133 443]
Reading package lists... Done
E: The repository 'http://pkg.jenkins.io/debian-stable binary/ Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
drc@iZwz91oq31508figapkas0Z:~$
再来一次sudo apt-get update
qiang@09230:~$ sudo apt-get update
Hit:1 http://mirrors.cloud.aliyuncs.com/ubuntu focal InRelease
Hit:2 http://mirrors.cloud.aliyuncs.com/ubuntu focal-updates InRelease
Hit:3 http://mirrors.cloud.aliyuncs.com/ubuntu focal-backports InRelease
Hit:4 http://mirrors.cloud.aliyuncs.com/ubuntu focal-security InRelease
Hit:6 http://ppa.launchpad.net/mosquitto-dev/mosquitto-ppa/ubuntu focal InRelease
Ign:5 https://pkg.jenkins.io/debian-stable binary/ InRelease
Get:7 https://pkg.jenkins.io/debian-stable binary/ Release [2,044 B]
Get:8 https://pkg.jenkins.io/debian-stable binary/ Release.gpg [833 B]
Get:9 https://pkg.jenkins.io/debian-stable binary/ Packages [21.9 kB]
Fetched 24.8 kB in 2s (11.9 kB/s)
Reading package lists... Done
qiang@09230:~$
2.4、安装jenkins
sudo apt-get install jenkins
如下则安装成功
qiang@09230:~$ sudo apt-get install jenkins
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
jenkins
0 upgraded, 1 newly installed, 0 to remove and 220 not upgraded.
Need to get 91.4 MB of archives.
After this operation, 95.0 MB of additional disk space will be used.
Err:1 https://pkg.jenkins.io/debian-stable binary/ jenkins 2.332.3
Could not wait for server fd - select (11: Resource temporarily unavailable) [IP: 151.101.74.133 443]
E: Failed to fetch https://pkg.jenkins.io/debian-stable/binary/jenkins_2.332.3_all.deb Could not wait for server fd - select (11: Resource temporarily unavailable) [IP: 151.101.74.133 443]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
qiang@09230:~$
3、启动Jenkins
启动
sudo service jenkins start
或
sudo systemctl start jenkins
查看jenkins运行状态
如下显示active处于活跃状态
qiang@09230:~$ systemctl status jenkins
● jenkins.service - Jenkins Continuous Integration Server
Loaded: loaded (/lib/systemd/system/jenkins.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2022-05-18 17:53:44 CST; 1h 51min ago
Main PID: 369083 (java)
Tasks: 46 (limit: 9105)
Memory: 2.3G
CGroup: /system.slice/jenkins.service
└─369083 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war --webroot=/var/cache/jenkins/war --httpPort=8080
qiang@09230:~$
设置jenkins跟随系统开机自启动
sudo systemctl enable jenkins
4、访问Jenkins
此时输入网址在服务器的8080端口下可以访问Jenkins
按如下图指引建立Jenkins账号并登录:
把jinkins配置在80808端口以免占用8080端口
以上,安装Jenkins成功!