gitlab 在线地址 https://gitlab.awbeci.com/ https://gitlab.com/gitlab-com
对应的v4版本的API文档 https://gitlab.awbeci.com/help/api/api_resources.md
Most API requests require authentication, or only return public data when authentication isn’t provided. When authentication is not required, the documentation for each endpoint specifies this. For example, the /projects/:id endpoint does not require authentication.【还需要是public的】
DELETE /projects/:id/merge_requests/:merge_request_iid/discussions/:discussion_id/notes/:note_id
PUT /projects/:id/merge_requests/:merge_request_iid/discussions/:discussion_id/notes/:note_id
POST /projects/:id/merge_requests/:merge_request_iid/discussions/:discussion_id/notes
PUT /projects/:id/merge_requests/:merge_request_iid/discussions/:discussion_id
POST /projects/:id/merge_requests/:merge_request_iid/discussions
GET /projects/:id/merge_requests/:merge_request_iid/discussions/:discussion_id
curl --location --request GET 'https://gitlab.awbeci.com/api/v4/projects/62/merge_requests'
[
{
"id": 34,
"iid": 1,
"project_id": 62,
"title": "WIP: Resolve \"issue01\"",
"description": "Closes #1",
"state": "opened",
"created_at": "2021-05-23T06:25:22.054Z",
"updated_at": "2021-05-23T07:48:13.435Z",
"merged_by": null,
"merged_at": null,
"closed_by": null,
"closed_at": null,
"target_branch": "master",
"source_branch": "1-issue01",
"user_notes_count": 1,
"upvotes": 0,
"downvotes": 1,
"assignee": null,
"author": {
"id": 25,
"name": "xiaolixi",
"username": "xiaolixi",
"state": "active",
"avatar_url": "https://gitlab.awbeci.com/uploads/-/system/user/avatar/25/avatar.png",
"web_url": "https://gitlab.awbeci.com/xiaolixi"
},
"assignees": [],
"source_project_id": 62,
"target_project_id": 62,
"labels": [],
"work_in_progress": true,
"milestone": null,
"merge_when_pipeline_succeeds": false,
"merge_status": "cannot_be_merged",
"sha": "5d999e9db08c938db35e1aa126ecf3eb8fc61b3c",
"merge_commit_sha": null,
"squash_commit_sha": null,
"discussion_locked": null,
"should_remove_source_branch": null,
"force_remove_source_branch": true,
"reference": "!1",
"references": {
"short": "!1",
"relative": "!1",
"full": "tomgroup/tomproject01!1"
},
"web_url": "https://gitlab.awbeci.com/tomgroup/tomproject01/-/merge_requests/1",
"time_stats": {
"time_estimate": 0,
"total_time_spent": 0,
"human_time_estimate": null,
"human_total_time_spent": null
},
"squash": false,
"task_completion_status": {
"count": 0,
"completed_count": 0
},
"has_conflicts": true,
"blocking_discussions_resolved": true,
"approvals_before_merge": null
}
]
curl --location --request GET 'https://gitlab.awbeci.com/api/v4/projects/62/merge_requests/1'
{
"id": 34,
"iid": 1,
"project_id": 62,
"title": "WIP: Resolve \"issue01\"",
"description": "Closes #1",
"state": "opened",
"created_at": "2021-05-23T06:25:22.054Z",
"updated_at": "2021-05-23T07:48:13.435Z",
"merged_by": null,
"merged_at": null,
"closed_by": null,
"closed_at": null,
"target_branch": "master",
"source_branch": "1-issue01",
"user_notes_count": 1,
"upvotes": 0,
"downvotes": 1,
"assignee": null,
"author": {
"id": 25,
"name": "xiaolixi",
"username": "xiaolixi",
"state": "active",
"avatar_url": "https://gitlab.awbeci.com/uploads/-/system/user/avatar/25/avatar.png",
"web_url": "https://gitlab.awbeci.com/xiaolixi"
},
"assignees": [],
"source_project_id": 62,
"target_project_id": 62,
"labels": [],
"work_in_progress": true,
"milestone": null,
"merge_when_pipeline_succeeds": false,
"merge_status": "cannot_be_merged",
"sha": "5d999e9db08c938db35e1aa126ecf3eb8fc61b3c",
"merge_commit_sha": null,
"squash_commit_sha": null,
"discussion_locked": null,
"should_remove_source_branch": null,
"force_remove_source_branch": true,
"reference": "!1",
"references": {
"short": "!1",
"relative": "!1",
"full": "tomgroup/tomproject01!1"
},
"web_url": "https://gitlab.awbeci.com/tomgroup/tomproject01/-/merge_requests/1",
"time_stats": {
"time_estimate": 0,
"total_time_spent": 0,
"human_time_estimate": null,
"human_total_time_spent": null
},
"squash": false,
"task_completion_status": {
"count": 0,
"completed_count": 0
},
"has_conflicts": true,
"blocking_discussions_resolved": true,
"approvals_before_merge": null,
"subscribed": true,
"changes_count": null,
"latest_build_started_at": null,
"latest_build_finished_at": null,
"first_deployed_to_production_at": null,
"pipeline": null,
"head_pipeline": null,
"diff_refs": {
"base_sha": "5d999e9db08c938db35e1aa126ecf3eb8fc61b3c",
"head_sha": "5d999e9db08c938db35e1aa126ecf3eb8fc61b3c",
"start_sha": "5d999e9db08c938db35e1aa126ecf3eb8fc61b3c"
},
"merge_error": null,
"first_contribution": false,
"user": {
"can_merge": true
}
}
curl --location --request GET 'https://gitlab.awbeci.com/api/v4/projects/62/merge_requests/1/discussions' \
--header 'PRIVATE-TOKEN: EooWXSL3KHSneaZBpzuv'
[
{
"id": "268f991e79b1d7b9d480a44e2b04bfca9a98384d",
"individual_note": true,
"notes": [
{
"id": 89,
"type": null,
"body": "first diss 透明色",
"attachment": null,
"author": {
"id": 25,
"name": "xiaolixi",
"username": "xiaolixi",
"state": "active",
"avatar_url": "https://gitlab.awbeci.com/uploads/-/system/user/avatar/25/avatar.png",
"web_url": "https://gitlab.awbeci.com/xiaolixi"
},
"created_at": "2021-05-23T07:48:13.419Z",
"updated_at": "2021-05-23T07:48:13.419Z",
"system": false,
"noteable_id": 34,
"noteable_type": "MergeRequest",
"resolvable": false,
"confidential": null,
"noteable_iid": 1,
"commands_changes": {}
}
]
},
{
"id": "0d8cdc72d9c425e44be27a84219cd486ce858578",
"individual_note": true,
"notes": [
{
"id": 90,
"type": null,
"body": "第二个讨论",
"attachment": null,
"author": {
"id": 25,
"name": "xiaolixi",
"username": "xiaolixi",
"state": "active",
"avatar_url": "https://gitlab.awbeci.com/uploads/-/system/user/avatar/25/avatar.png",
"web_url": "https://gitlab.awbeci.com/xiaolixi"
},
"created_at": "2021-05-23T08:20:07.315Z",
"updated_at": "2021-05-23T08:20:07.315Z",
"system": false,
"noteable_id": 34,
"noteable_type": "MergeRequest",
"resolvable": false,
"confidential": null,
"noteable_iid": 1,
"commands_changes": {}
}
]
}
]
curl --location --request POST 'https://gitlab.awbeci.com/api/v4/projects/62/merge_requests/1/discussions?body=MR%E7%9A%84%E8%AF%84%E8%AE%BA%EF%BC%8C%E5%8F%AF%E4%BB%A5%E5%8A%A0notes%E7%9A%84%E8%AF%84%E8%AE%BA'
{
"id": "147509142b2d7bd1b24ba1594d5f168ff4ee9b0f",
"individual_note": false,
"notes": [
{
"id": 91,
"type": "DiscussionNote",
"body": "MR的评论,可以加notes的评论",
"attachment": null,
"author": {
"id": 25,
"name": "xiaolixi",
"username": "xiaolixi",
"state": "active",
"avatar_url": "https://gitlab.awbeci.com/uploads/-/system/user/avatar/25/avatar.png",
"web_url": "https://gitlab.awbeci.com/xiaolixi"
},
"created_at": "2021-05-23T08:41:21.641Z",
"updated_at": "2021-05-23T08:41:21.641Z",
"system": false,
"noteable_id": 34,
"noteable_type": "MergeRequest",
"resolvable": true,
"resolved": false,
"resolved_by": null,
"confidential": null,
"noteable_iid": 1,
"commands_changes": {}
}
]
}