1.场景
对于信息部而言,需求实现的一般流程为“业务提出需求-研发开发需求-测试审核需求-业务验收需求”,其中研发的开发一般发生于代码平台,其他流程在数知鸟平台发生,那么如何在数知鸟就能及时了解研发的代码审核进度呢?
数知鸟支持集成代码平台,在数知鸟内实时推送代码平台中的代码开发进度,节省人工通知时间、简化跨平台查看进度的操作,让研发进度更透明,便于测试展开后续工作。
下文以Gitlab为例。
| 视频教程(建议观看)
2.Gitlab集成设置
2.1新增测试webhook
「设置」>「webhooks」,根据帮助文档进行操作、在图中步骤3处贴入测试webhook链接,勾选“合并请求事件”,点击“添加webhook”
2.2了解请求结构与内容
注:此步骤需要做出有效动作以获取请求内容
提交测试分支并申请合并,在帮助文档地址中获取请求并查看请求内容,发现关键信息处于请求中的body结构中,具体信息如下,有效信息为请求类别object_kind/操作者username/代码任务名称title/代码状态state/代码地址url/分支source_branch/目标分支target_branch
{ "object_kind": "merge_request", "event_type": "merge_request", "user": { "id": 31717, "name": "wei lai", "username": "weilai", "avatar_url": null, "email": "[REDACTED]" }, "project": { "id": 75877, "name": "Learn GitLab - Ultimate trial", "description": "Learn how to use GitLab to support your software development life cycle.", "web_url": "https://jihulab.com/weilai1/learn-gitlab-ultimate-trial", "avatar_url": "https://jihulab.com/uploads/-/system/project/avatar/75877/Artboard.jpg", "git_ssh_url": "git@jihulab.com:weilai1/learn-gitlab-ultimate-trial.git", "git_http_url": "https://jihulab.com/weilai1/learn-gitlab-ultimate-trial.git", "namespace": "weilai", "visibility_level": 0, "path_with_namespace": "weilai1/learn-gitlab-ultimate-trial", "default_branch": "master", "ci_config_path": "", "homepage": "https://jihulab.com/weilai1/learn-gitlab-ultimate-trial", "url": "git@jihulab.com:weilai1/learn-gitlab-ultimate-trial.git", "ssh_url": "git@jihulab.com:weilai1/learn-gitlab-ultimate-trial.git", "http_url": "https://jihulab.com/weilai1/learn-gitlab-ultimate-trial.git" }, "object_attributes": { "assignee_id": null, "author_id": 31717, "created_at": "2022-11-30 20:21:21 +0800", "description": "", "head_pipeline_id": null, "id": 186306, "iid": 1, "last_edited_at": null, "last_edited_by_id": null, "merge_commit_sha": null, "merge_error": null, "merge_params": { "force_remove_source_branch": "1" }, "merge_status": "preparing", "merge_user_id": null, "merge_when_pipeline_succeeds": false, "milestone_id": null, "source_branch": "dev", "source_project_id": 75877, "state_id": 1, "target_branch": "master", "target_project_id": 75877, "time_estimate": 0, "title": "EP-1 更新 README.md", "updated_at": "2022-11-30 20:21:21 +0800", "updated_by_id": null, "url": "https://jihulab.com/weilai1/learn-gitlab-ultimate-trial/-/merge_requests/1", "source": { "id": 75877, "name": "Learn GitLab - Ultimate trial", "description": "Learn how to use GitLab to support your software development life cycle.", "web_url": "https://jihulab.com/weilai1/learn-gitlab-ultimate-trial", "avatar_url": "https://jihulab.com/uploads/-/system/project/avatar/75877/Artboard.jpg", "git_ssh_url": "git@jihulab.com:weilai1/learn-gitlab-ultimate-trial.git", "git_http_url": "https://jihulab.com/weilai1/learn-gitlab-ultimate-trial.git", "namespace": "weilai", "visibility_level": 0, "path_with_namespace": "weilai1/learn-gitlab-ultimate-trial", "default_branch": "master", "ci_config_path": "", "homepage": "https://jihulab.com/weilai1/learn-gitlab-ultimate-trial", "url": "git@jihulab.com:weilai1/learn-gitlab-ultimate-trial.git", "ssh_url": "git@jihulab.com:weilai1/learn-gitlab-ultimate-trial.git", "http_url": "https://jihulab.com/weilai1/learn-gitlab-ultimate-trial.git" }, "target": { "id": 75877, "name": "Learn GitLab - Ultimate trial", "description": "Learn how to use GitLab to support your software development life cycle.", "web_url": "https://jihulab.com/weilai1/learn-gitlab-ultimate-trial", "avatar_url": "https://jihulab.com/uploads/-/system/project/avatar/75877/Artboard.jpg", "git_ssh_url": "git@jihulab.com:weilai1/learn-gitlab-ultimate-trial.git", "git_http_url": "https://jihulab.com/weilai1/learn-gitlab-ultimate-trial.git", "namespace": "weilai", "visibility_level": 0, "path_with_namespace": "weilai1/learn-gitlab-ultimate-trial", "default_branch": "master", "ci_config_path": "", "homepage": "https://jihulab.com/weilai1/learn-gitlab-ultimate-trial", "url": "git@jihulab.com:weilai1/learn-gitlab-ultimate-trial.git", "ssh_url": "git@jihulab.com:weilai1/learn-gitlab-ultimate-trial.git", "http_url": "https://jihulab.com/weilai1/learn-gitlab-ultimate-trial.git" }, "last_commit": { "id": "a8629e88b02abfd346d06bda8da86f85205e12bf", "message": "更新 README.md", "title": "更新 README.md", "timestamp": "2022-11-30T12:17:15+00:00", "url": "https://jihulab.com/weilai1/learn-gitlab-ultimate-trial/-/commit/a8629e88b02abfd346d06bda8da86f85205e12bf", "author": { "name": "wei lai", "email": "171706193@qq.com" } }, "work_in_progress": false, "total_time_spent": 0, "time_change": 0, "human_total_time_spent": null, "human_time_change": null, "human_time_estimate": null, "assignee_ids": [], "reviewer_ids": [], "labels": [], "state": "opened", "blocking_discussions_resolved": true, "first_contribution": false, "detailed_merge_status": "checking", "action": "open" }, "labels": [], "changes": { "merge_status": { "previous": "unchecked", "current": "preparing" } }, "repository": { "name": "Learn GitLab - Ultimate trial", "url": "git@jihulab.com:weilai1/learn-gitlab-ultimate-trial.git", "description": "Learn how to use GitLab to support your software development life cycle.", "homepage": "https://jihulab.com/weilai1/learn-gitlab-ultimate-trial" }}
2.3新增正式webhook
将4.1数知鸟新增集成服务中的“webhook地址”贴入Gitlab内webhook接收位中,重复2.1操作
3.数知鸟基础设置
1)在需求类型设置中新增下拉字段“代码合并状态”
2)数知鸟中新增对应代码需求,后续代码标题以需求id为前缀
4.数知鸟集成设置
4.1新增“集成服务”
「设置」>「集成配置」>「集成服务」,新增配置、设置集成名称。
4.2配置“集成服务”
1)设置动态数据映射
将2.2中了解到的有效信息设置为动态数据映射,具体信息根据请求内容及实际场景而定,下图仅供参考
2)在webhook卡片中设置集成服务作用空间
3)新增“添加条件”步骤并配置
由于在测试中我们发现gitlab中每一步操作会发送3条请求,而其中的有效请求只有请求类别为“merge_request”的请求,因为需要在此次卡片中过滤出有效请求、防止做出无意义的重复动作
4)新增“筛选需求”并配置
筛选出对应的数知鸟需求“需求id=任务标题”,从而推送该需求对应的代码合并状态
5)新增“变更字段值”并配置
为了让代码合并状态变更更明显,在此步骤中根据代码真实状态、变更该需求中对应的“代码合并字段”字段值
6)新增“提交备注”步骤并配置
通过提交备注,对上述“代码合并状态”变更进行更详细的解释
4)保存
4.检验
在Gitlab中进行提交代码操作,在集成服务列表中,可点击查看具体运行情况,了解是否成功运行