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

相关推荐
一苓二肆41 分钟前
Git 常用指令总结(工程实战版)
大数据·git·elasticsearch
迎仔42 分钟前
10-算力中心运维三剑客:Ansible + Jenkins + K8s 高效实战
运维·kubernetes·ansible·jenkins
weixin_5316518110 小时前
Elasticsearch 检索原理分析
大数据·elasticsearch·jenkins
叶 落13 小时前
Windows 安装 Git
git
聂 可 以14 小时前
Windows环境Git安装教程(下载Git安装包、安装Git、验证Git是否安装成功)
windows·git
阿寻寻15 小时前
【云原生技术】git checkout --.什么意思
git
secondyoung17 小时前
Git使用:Git使用问题及解决方法总结
windows·经验分享·git·vscode·gitee·github·gitcode
海兰1 天前
Elasticsearch 9.3.0 日志数据源配置
大数据·elasticsearch·jenkins
周杰伦fans1 天前
Android Studio Git 管理最佳实践
git·elasticsearch·android studio
承渊政道1 天前
Linux系统学习【深入剖析Git的原理和使用(下)】
linux·服务器·git·学习·gitee·vim·gitcode