官网下载安装包比较慢,推荐去清华源进行下载。
安装
Jenkins基于Java实现,安装前要先准备JDK环境。
- CentOS
# 安装JDK
[root@centos7 ~]#yum -y install java-11-openjdk
[root@centos7 ~]#java -version
openjdk version "11.0.8" 2020-07-14 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.8+10-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.8+10-LTS, mixed mode, sharing)
# 安装Jenkins
[root@centos7 ~]#yum -y install jenkins-2.263.2-1.1.noarch.rpm
# 查看安装文件
[root@centos7 ~]#rpm -ql jenkins
/etc/init.d/jenkins
/etc/logrotate.d/jenkins
/etc/sysconfig/jenkins
/usr/lib/jenkins
/usr/lib/jenkins/jenkins.war
/usr/sbin/rcjenkins
/var/cache/jenkins
/var/lib/jenkins
/var/log/jenkins
# 启动Jenkins
[root@centos7 ~]#systemctl start jenkins
- Ubuntu
# 安装JDK
[root@ubuntu1804:~]# apt -y install openjdk-11-jdk
[root@ubuntu1804:~]# java -version
openjdk version "11.0.9.1" 2020-11-04
OpenJDK Runtime Environment (build 11.0.9.1+1-Ubuntu-0ubuntu1.18.04)
OpenJDK 64-Bit Server VM (build 11.0.9.1+1-Ubuntu-0ubuntu1.18.04, mixed mode, sharing)
# 安装Jenkins
# 安装Jenkins依赖于daemon包,需要提前安装
[root@ubuntu1804:~]# apt -y install daemon
[root@ubuntu1804:~]# dpkg -i jenkins_2.235.5_all.deb
# 查看安装文件
[root@ubuntu1804:~]# dpkg -S jenkins
jenkins: /etc/init.d/jenkins
jenkins: /etc/logrotate.d/jenkins
jenkins: /var/log/jenkins
jenkins: /usr/share/doc/jenkins/changelog.gz
jenkins: /usr/share/doc/jenkins
jenkins: /usr/share/doc/jenkins/copyright
jenkins: /var/cache/jenkins
jenkins: /etc/default/jenkins
jenkins: /var/lib/jenkins
jenkins: /usr/share/jenkins/jenkins.war
jenkins: /usr/share/jenkins
修改镜像源
# 修改插件源地址,加速部署
[root@ubuntu1804:~]# vim /var/lib/jenkins/hudson.model.UpdateCenter.xml
<?xml version='1.1' encoding='UTF-8'?>
<sites>
<site>
<id>default</id>
<url>https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json</url>
</site>
</sites>
# 使用sed命令修改
[root@centos7 jenkins]#sed -i 's@https://updates.jenkins.io/update-center.json@https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json@i' /var/lib/jenkins/hudson.model.UpdateCenter.xml
[root@centos7 jenkins]#sed -i 's@https://updates.jenkins.io/download/@https://mirrors.tuna.tsinghua.edu.cn/jenkins/@g' /var/lib/jenkins/updates/default.json
# 修改后重启Jenkins
[root@ubuntu1804:~]# systemctl restart jenkins.service