实验一:Gitlab+jenkins+web-server(tomcat)
更换了存放项目的仓库 gitlab 私有仓库(本地) 源码的下载速度也会提升
gitlab正常使用,gitlab仓库, cloud 项目上传到仓库
注意:在提交代码
有git命令,安装git,添加全局配置(username email)
git config —global user.email “xingdianvip@gmail.com”
git config —global user.name “xingdian”
取消gitlab中cloud的仓库main分支的保护(能够向main这个分支提交代码)
如果使用域名做本地解析,在gitlab添加提交服务器的公钥
git clone git@gitlab.example.com:xingdian/cloud.git
将项目压缩包上传到服务器 .zip 解压 并把解压后的内容拷贝到仓库目录下
git提交代码到cloud仓库 main分支
项目上传到仓库(操作)
更换成gitlab仓库地址
去掉gitlab的认证
实验二:GitHub+jenkins+web-server(tomcat) 构建的时候 网络连接超时(正常现象) githud仓库地址
1.安装对应的插件(jenkins)
Deploy to container
Git (插件比较多)
Maven Integration
Publish Over SSH
2.配置ssh
添加jenkins的私钥到key的位置
配置web-server的相关信息(name,ip地址,用户,目录)
jenkins—-> web-server 免密
3.全局配置 git maven jdk 相关配置
4.创建任务
实验三:Gitlab+jenkins+web-server(tomcat)+webhook 自动发布
当我们修改仓库代码,提交的时候,提交完成他会自动触发jenkins,实验项目的自动发布
如果开发人员修改了代码;(钩子)利用webhook自动去代码仓库(gitlab)获取新的代码,在jenkins上利用maven进行构建;
构建完成后发布到web-server(新版本的上线【新版本自动化上线】)
1.jenkins
安装插件(Generic Webhook Trigger)
配置项目(上午cloud项目,在这个基础上做的修改)
在构建触发器:
在将更改推送到 GitLab 时进行构建。GitLab webhook URL: http://192.168.222.129:8080/jenkins/project/cloud
保证(gitlab的)webhook能够连接jenkins
配置 —-> gitlab /project 对勾去掉
全局安全配置 ——> 保证登录用户可以做任何事情(匿名用户具有可读权限)
2.gitlab
开启本地网络访问权限(目录:webhook能够连接jenkins)
menu —-> admin —->设置 —->网络 ——> 出站请求 允许即可
配置项目的webhook
项目cloud—->设置—->webhook (添加) 网址 :http://192.168.222.129:8080/jenkins/project/cloud (图见笔记) —-> 测试 200 ok
注:错误代码
500:jenkins错误,将Allow Branch 选项修改为“Allow all branches to trigger this job”:
403:jenkins错误,在Configure global Security 中勾选允许匿名注册,然后将系统管理中Gitlab选项中取消勾选Enable authentication for ‘/project’ end-point

text测试成功,Webhook不自动构建,检查item选项,是否选择gitee,可以手动test成功,修改之后不自动创建,将gitee修改为gitlab
3.gitlab(模拟项目代码的更新提交)
项目cloud —-> src/main/webapp/index.jsp —-> 修改完后记得提交 (观察jenkins对应的项目) 等待一段时候后,浏览器访问web-server
