Curl命令获取Gitlab中项目的所有管道

i1icjdpr  于 4个月前  发布在  Git
关注(0)|答案(1)|浏览(69)

有没有gitlab rest API命令可以获取gitlab中项目的所有管道?我目前试过的这个命令只能给我这个月的管道id。
下面是我执行的命令(遵循文档https://docs.gitlab.com/ee/api/pipelines.html):

curl --header "PRIVATE-TOKEN: <your gitlab access token>" "https://<your gitlab url>/api/v4/projects/<project_id>/pipelines"

字符串
但它只在过去的一个月里返回了管道,但我想要所有的管道,因为项目存在(请参阅json响应中的created_at字段,仅显示6月份的管道):

[ { "id": 64056, "project_id": 260, "sha": "ee38d9b75...c48a5e09d59ab", "ref": "Story-C", "status": "success", "created_at": "2023-06-30T19:18:48.678Z", "updated_at": "2023-06-30T19:19:39.619Z", "web_url": "https://test.gitlab.com/myproject/aa/Project1/-/pipelines/64178" }, { "id": 64055, "project_id": 260, "sha": "a16d08bf9e....6644b888f86bb", "ref": "Story-C", "status": "success", "created_at": "2023-06-30T18:59:23.613Z", "updated_at": "2023-06-30T19:07:19.710Z", "web_url": "https://test.gitlab.com/myproject/aa/Project1/-/pipelines/64176" }, { "id": 64054, "project_id": 260, "sha": "37abc11....2d314b9d04b71f", "ref": "Story-B", "status": "failed", "created_at": "2023-06-30T18:21:39.214Z", "updated_at": "2023-06-30T18:22:20.776Z", "web_url": "https://test.gitlab.com/myproject/aa/Project1/-/pipelines/64174" }, { "id": 64053, "project_id": 260, "sha": "37085619....b416591bc25c61", "ref": "Story-B", "status": "success", "created_at": "2023-06-30T17:35:15.761Z", "updated_at": "2023-06-30T17:36:10.963Z", "web_url": "https://test.gitlab.com/myproject/aa/Project1/-/pipelines/64173" }, { "id": 64052, "project_id": 260, "sha": "f1ae944c......a935821a6", "ref": "master", "status": "success", "created_at": "2023-06-30T14:41:42.554Z", "updated_at": "2023-06-30T14:42:26.583Z", "web_url": "https://test.gitlab.com/myproject/aa/Project1/-/pipelines/64172" }, { "id": 64051, "project_id": 260, "sha": "9e80dafc......e2b6222679c6", "ref": "Story-A", "status": "success", "created_at": "2023-06-30T14:39:03.073Z", "updated_at": "2023-06-30T14:39:53.794Z", "web_url": "https://test.gitlab.com/myproject/aa/Project1/-/pipelines/64171" }, { "id": 64050, "project_id": 260, "sha": "d31c96bad......1446a3e67a8fa3", "ref": "Story-A", "status": "success", "created_at": "2023-06-30T14:32:19.431Z", "updated_at": "2023-06-30T14:33:21.138Z", "web_url": "https://test.gitlab.com/myproject/aa/Project1/-/pipelines/64170" }, { "id": 64049, "project_id": 260, "sha": "746073226....af93aa06269f", "ref": "Story-A_logging", "status": "success", "created_at": "2023-06-28T15:13:18.343Z", "updated_at": "2023-06-28T15:14:08.113Z", "web_url": "https://test.gitlab.com/myproject/aa/Project1/-/pipelines/64145" }, { "id": 64048, "project_id": 260, "sha": "6c1a5e00a6....de9258c685383", "ref": "Story-A_logging", "status": "success", "created_at": "2023-06-20T14:25:26.167Z", "updated_at": "2023-06-20T14:32:29.525Z", "web_url": "https://test.gitlab.com/myproject/aa/Project1/-/pipelines/64101" }, { "id": 64047, "project_id": 260, "sha": "871258abbc....e825406fd8ce", "ref": "Story-A", "status": "success", "created_at": "2023-06-13T15:41:52.916Z", "updated_at": "2023-06-13T15:42:42.485Z", "web_url": "https://test.gitlab.com/myproject/aa/Project1/-/pipelines/64068" }, { "id": 64046, "project_id": 260, "sha": "6a2be8fced....216f7cffd2", "ref": "Story-A", "status": "success", "created_at": "2023-06-08T19:49:42.212Z", "updated_at": "2023-06-12T15:49:00.510Z", "web_url": "https://test.gitlab.com/myproject/aa/Project1/-/pipelines/64048" }, { "id": 64045, "project_id": 260, "sha": "57a88d64......1942f2475824", "ref": "Story-A", "status": "success", "created_at": "2023-06-08T16:15:18.815Z", "updated_at": "2023-06-08T16:17:15.850Z", "web_url": "https://test.gitlab.com/myproject/aa/Project1/-/pipelines/64047" }, { "id": 64044, "project_id": 260, "sha": "b6b455....7568c541653e", "ref": "Story-A", "status": "success", "created_at": "2023-06-08T15:56:15.097Z", "updated_at": "2023-06-08T15:57:26.963Z", "web_url": "https://test.gitlab.com/myproject/aa/Project1/-/pipelines/64046" }, { "id": 64043, "project_id": 260, "sha": "8f212....57baaddc091a", "ref": "Story-A", "status": "success", "created_at": "2023-06-07T20:04:33.353Z", "updated_at": "2023-06-07T20:05:41.616Z", "web_url": "https://test.gitlab.com/myproject/aa/Project1/-/pipelines/64043" }, { "id": 64042, "project_id": 260, "sha": "0c9113eb1......b1efbf628ea9a", "ref": "Story-A", "status": "success", "created_at": "2023-06-07T19:53:33.848Z", "updated_at": "2023-06-07T19:55:02.234Z", "web_url": "https://test.gitlab.com/myproject/aa/Project1/-/pipelines/64042" }, { "id": 64041, "project_id": 260, "sha": "e123007a14ec89aa4......b0c41800b", "ref": "Story-A", "status": "success", "created_at": "2023-06-07T19:42:09.780Z", "updated_at": "2023-06-07T19:46:37.742Z", "web_url": "https://test.gitlab.com/myproject/aa/Project1/-/pipelines/64041" }, { "id": 64040, "project_id": 260, "sha": "7f85108cc......21420ba", "ref": "Story-A", "status": "success", "created_at": "2023-06-07T18:41:33.447Z", "updated_at": "2023-06-07T18:43:07.849Z", "web_url": "https://test.gitlab.com/myproject/aa/Project1/-/pipelines/64040" } ]

lvmkulzt

lvmkulzt1#

正如@sytech在回应中提到的,答案是API是分页的。
这只会得到最新的20个条目。
curl --header“PRIVATE-TOKEN:““https:/api/v4/projects/<project_id>/pipelines”
但是他提供的链接https://docs.gitlab.com/ee/api/rest/#pagination要求您向API添加更多参数,以从过去获得更多数据。
知道这一点后,我添加了?page=x,其中x是任何页码,如2、3或10或更多。
所以API调用现在是:
curl --header“PRIVATE-TOKEN:““https:/api/v4/projects/<project_id>/pipelines?page=4”
此外,链接显示我们可以使用per_page=x参数,您可以将其定义为每个请求返回多达100个项目,因此API调用将是:
curl --header“PRIVATE-TOKEN:““https:/api/v4/projects/<project_id>/pipelines?per_page=100”

相关问题