Git-GitLab-Jenkins结合

目录

1.Git-GitLab-Jenkins结合

2. 在pycharm配置git

Settings-Version control-Git

pycharm工具栏-VCS-Get from Version Control

将项目代码复制到刚拉下来的仓库中,然后单独打开该项目


3. 实现提交代码后触发自动化测试

(1)打开gitlab

选择【Outbound requests】

(2)Jenkins配置Git

jenkins安装git插件--直接安装

在工程中进行设置

还可以指定分支

点击Gredentials【添加】

生成路径和token--gitlab配置时需要用到

向下滑动--点击【高级】

(3)选择需要的远程仓库

点击Settings-选择Webhooks-配置jenkins信息-(工程路径和token权限)

选择【push events】,只要提交就会触发事件

保存配置并测试

如果配置成功,

  • 则jenkins会新增一条构建记录
  • jenkins挂载目录中会拉取到代码

4.报告存在问题:

在项目中新建配置文件enviroment.properties并传到gitlab:

python 复制代码
Browser=Firefox
Browser.Version=77
Stand=szzz_delivery
ApiUrl=http://121/41/14/39:8082/shop/index.html#/login
python.Version=3.6.5

在jenkins中shell脚本添加copy指令,将配置文件复制到allure-results中

powershell 复制代码
cd Delivery_System_0908/testCase
pytest -s --allureddir=${WORKSPACE}/allure-results
cp ${WORKSPACE}/Delivery_System_0908/enviroment.properties ${WORKSPACE}/allure-results/enviroment.properties
exit 0


[说明]

【发现构建时间和代码提交时间不一致】

powershell 复制代码
#更新同步服务器宿主机时间--
ntpdate ntp1.aliyun.com
# 容器时间
docker exec -it 容器id /bin/bash
#查看时间,如果发现不正确
date
#退出容器
exit
#更新 将时间同步到容器中
docker cp /usr/share/zoneinfo/Asia/Shanghai 容器id:/etc/localtime
#重启容器
docker restart 容器id
还不行的话就在jenkins中修改时区

5.也可以在Jenkins中设置定时触发,以上是webhook触发

WebHooks--勾子

目标:希望在代码被push,jenkins会自动构建

是一个url,携带特定参数,一种web回调或者http的push API,是向APP或其他应用提供实时信息的方式。

Webhook在数据产生时立即发送数据,也就是能实时收到数据

相关推荐
德彪稳坐倒骑驴14 小时前
Git常用命令
git
无限进步_14 小时前
【C语言&数据结构】对称二叉树:镜像世界的递归探索
c语言·开发语言·数据结构·c++·git·算法·visual studio
qq_54702617917 小时前
Git 使用指南
git
XiaoHu020718 小时前
Linux多线程(详细全解)
linux·运维·服务器·开发语言·c++·git
*才华有限公司*19 小时前
RTSP视频流播放系统
java·git·websocket·网络协议·信息与通信
juelianhuayao20 小时前
Git错误提交后如何快速删除本次commit
git
chen<>20 小时前
Git原理与应用
大数据·git·elasticsearch·svn
小兔崽子去哪了21 小时前
Git 专题
git
金米kk21 小时前
git pull时报错Your local changes to the following files would…的解决办法
git
超级罗伯特21 小时前
git一次性完成仓库下载及所有分支获取
git·git仓库拉取