1、下载jenkins
- curl -O :下载并以不同的文件名保存
- um的repo中默认没有Jenkins,需要先将Jenkins存储库添加到yum repos,执行下面的命令:
- rpm安装
curl -o /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
2、添加key
rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
3、安装Jenkins
- 下载指定版本的rpm文件,进行rpm进行安装
# 在线安装yum install -y jenkins# 或 离线rpm安装rpm -ivh jenkins-2.156-1.1.noarch.rpm
4、启动jenkins
systemctl jenkins startsystemctl start jenkins
5 、停用jenkins
systemctl jenkins stopsystemctl stop jenkins
6、重启jenkins
systemctl jenkins restartsystemctl restart jenkins
7、设置开机启动
systemctl enable jenkins
8、安装默认的目录
/usr/lib/jenkins/jenkins.war WAR包 /etc/sysconfig/jenkins 配置文件/var/lib/jenkins/ 默认的JENKINS_HOME目录/var/log/jenkins/jenkins.log
9、修改sysconfig的Jenkins文件
- JENKINS_USER访问用户,默认为Jenkins,把它改成root
vim /etc/sysconfig/jenkins-----------------------------------------------------------------------# 指定目录JENKINS_HOME="/home/jenkins"# 访问用户,默认为Jenkins,把它改成rootJENKINS_USER="root"# 修改端口JENKINS_PORT="8080"
![ece0b956b5e287e7a3a58101d9118ae0.png](https://i-blog.csdnimg.cn/blog_migrate/21ed983d40596bcb2993285e150b54b4.jpeg)
10、给指定root用户进行授权
chown -R root:root /var/lib/jenkinschown -R root:root /var/cache/jenkinschown -R root:root /var/log/jenkins
11、创建jenkins目录
- JENKINS_HOME directory does not exist: /home/jenkins
mkdir /home/jenkins
12. 修改jenkins的配置文件
- whereis java 找到jdk安装目录 找到candidates="在它到后面添加jdk安装的目录,然后vi保存退出
vi /etc/init.d/jenkins
![08684556ae22019fea0796ce4eaf9e3b.png](https://i-blog.csdnimg.cn/blog_migrate/47af7b93788756c7411458b50a4aa62f.jpeg)
红帽子官方下载地址 https://pkg.jenkins.io/redhat/