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

相关推荐
Slow菜鸟5 小时前
Git Worktree 使用教程
大数据·git·elasticsearch
Warren985 小时前
Windows 本地安装 Jenkins 教程
linux·运维·windows·功能测试·mysql·jenkins
阿民不加班19 小时前
【Git】git拉取远端但是本地存在不想提交文件处理
git
Selina K20 小时前
在windows安装git
git
FreeBuf_1 天前
黑客滥用 GitHub 和 GitLab 托管恶意软件并实施凭证钓鱼攻击
gitlab·github
周杰伦fans1 天前
如何将 Feature 分支同步到 Master 主分支:一次完整的 Git 合并实战
git
jiayi_19991 天前
git创建new branch
git
__Witheart__1 天前
通过交互式 Rebase 合并部分提交到远程分支的操作步骤
git
魔都吴所谓1 天前
【Tools】Repo 工具完整使用手册
git
tianyuanwo1 天前
跨 Gerrit 项目迁移分支并保留完整历史:一份可操作的 Git 指南
git·代码迁移