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在数据产生时立即发送数据,也就是能实时收到数据

相关推荐
减瓦1 天前
Windows 环境使用 Git Bash 最佳实践
windows·git
史呆芬1 天前
CodeX多仓库提交Skill搭建
git·后端·openai
城东1 天前
Git使用[原意要新建分支提交但是误提交到原来分支恢复办法]
git·原意要新建分支提交·但是误提交到原来分支
开发者联盟league1 天前
git 压缩本地最近多个commit
git
赵庆明老师2 天前
Vben精讲:04-了解VSCode中的Git
ide·git·vscode
Irissgwe2 天前
第 5 篇:Git 分支基础:branch、checkout、merge 和冲突解决
git
liberalhumblehopeful2 天前
git代码管理-分支差距过大如何进行同步
git
一只楚楚猫2 天前
一篇文章入门Git工具
git
Irissgwe2 天前
第 6 篇:Git 分支进阶:分支策略、stash、bugfix 和 feature 开发
git