1.确保linux系统已安装jdk
2.下载Jenkins库:wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
(wget未安装的可执行安装:yum -y install wget )
3.导入key:rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
4.安装Jenkins:yum install -y jenkins
5.配置端口和权限:vi /etc/sysconfig/jenkins
JENKINS_PORT="8080" JENKINS_USER="root"
修改目录权限
chown -R root:root /var/lib/jenkins chown -R root:root /var/cache/jenkins chown -R root:root /var/log/jenkins
6.进入jdk安装目录: cd /usr/opt/jdk1.8.0_271/
创建软连接:ln -s /usr/opt/jdk1.8.0_271/bin/java /usr/bin/java
7.修改镜像:vi /var/lib/jenkins/hudson.model.UpdateCenter.xml
<?xml version='1.1' encoding='UTF-8'?> <sites> <site> <id>default</id> <url>http://mirror.xmission.com/jenkins/updates/update-center.json</url> </site> </sites>
8.启动Jenkins服务:service jenkins start
9.访问jenkins:http://ip(你的ip):8080(你的端口号)
cat /var/lib/jenkins/secrets/initialAdminPassword
例:
关闭jenkins
jenkins启动后,在网址栏输入http://localhost:8080/exit,点击确认后,即可关闭jenkins
重启
卸载:rpm -e jenkins
是否卸载成功:rpm -ql jenkins
彻底删除残留文件:find / -iname jenkins | xargs -n 1000 rm -rf