Git 提交自动触发测试
核心原理:事件触发 + CLI 命令执行
on: push
),本质上都是在监听 Git 提交事件,并执行 Apifox 的测试命令。
常用平台集成示例
跨平台集成示例:GitHub Actions + Jenkins
场景设定
apifox run
命令,运行 Apifox 自动化测试步骤 1:配置 Jenkins 项目
步骤 2:获取 Webhook URL
在 Jenkins 插件管理中搜索并安装 “Generic Webhook Trigger” 插件,安装完成后重启 Jenkins。
在 Jenkins 的 Dashboard 面板中选中一个项目,进入 Configure 页面,启用 
你也可以自定义一个 Token,这时 Webhook URL 即 
Generic Webhook Trigger
。此时 Webhook URL 即 http://<你的 Jenkins 服务地址>/generic-webhook-trigger/invoke
。http://<你的 Jenkins 服务地址>/generic-webhook-trigger/invoke?token=<xxxxxx>
:点击保存后,将 Webhook URL 复制下来,该地址用于触发 Jenkins 执行测试任务。
步骤 3:配置 GitHub Webhook
http://<你的 Jenkins 服务地址>/generic-webhook-trigger/invoke?token=<xxxxxx>
application/json
Just the push event
或其他触发事件效果验证
Push 一次代码到 GitHub 仓库
Jenkins 会立即开始构建任务
在 Jenkins 中查看控制台输出和测试结果