5分钟搭建并使用 Jenkins
目前市面上非常主流的部署架构Jenkins,我们来说一下他的安装流程:
第一种方式:
(1)下载 http://mirrors.jenkins.io/war-stable/latest/jenkins.war
(2)java -jar jenkins.war --httpPort=8080
(3)打开浏览器进入链接 http://localhost:8080
(4)根据提示输入默认密码,安装相关的插件
第二种方式(yum安装):
[root@localhost ~]# wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
[root@localhost ~]# rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
[root@localhost ~]# yum install jenkins
# WAR包
/usr/lib/jenkins/jenkins.war
# 配置文件, 修改用户为:root
/etc/sysconfig/jenkins
# 默认的JENKINS_HOME目录
/var/lib/jenkins/
# Jenkins日志文件
/var/log/jenkins/jenkins.log
# 添加服务
[root@localhost ~]# service jenkins start
# 启动测试
[root@localhost ~]# systemctl start jenkins
Starting jenkins (via systemctl): [ 确定 ]
# 重启 jenkins
[root@localhost ~]# systemctl restart jenkins
实操:
(1)新建job
(2)Source Code Management
配置git仓库,这一步的操作主要是为了拉取代码
(3)Build
Maven Version: maven3
Goals:clean install -Dmaven.test.skip=true
(4)Execute Shell
编译后执行的脚本。