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

相关推荐
蜜獾云5 小时前
在Git中配置用户名和密码
git
scx_link7 小时前
通过git bash在本地创建分支,并推送到远程仓库中
开发语言·git·bash
醉颜凉8 小时前
Elasticsearch高性能优化:Bulk API大规模数据导入性能调优全攻略
elasticsearch·性能优化·jenkins
南大白8 小时前
IntelliJ IDEA 运行时的 JVM 本地内存溢出崩溃
git
码农小旋风9 小时前
Claude Code 基础用法大全:对话、分析、修改、测试、Git 和工作流
人工智能·git·chatgpt·claude
南大白10 小时前
Git 撤回提交完整方案
git
像风一样的男人@10 小时前
python --实现代理服务器
git·ui
sbjdhjd11 小时前
从零搭建企业级 CI/CD(下):Jenkins+GitLab+Harbor 全链路实战指南
git·servlet·ci/cd·云原生·云计算·gitlab·jenkins
码云数智-大飞11 小时前
Go Channel 详解:并发通信的正确姿势
前端·数据库·git
小美元11 小时前
【爽之】使用jenkins实现前端一键发版
运维·jenkins