简体   繁体   English

Gitlab:如何区分最新和以前的管道提交

[英]Gitlab: how to take difference between latest and previous pipeline commits

ive looking for method which i can use for getting all comments texts from commits added with last build pipeline in gitlab我正在寻找可用于从 gitlab 中的最后一个构建管道添加的提交中获取所有评论文本的方法

we can take commits sha key by using gitlab api, but this request dont getting any information about commit comments (sha key holding changed commits id):我们可以通过使用 gitlab api 来获取提交 sha 密钥,但是这个请求没有得到关于提交评论的任何信息(sha 密钥持有更改的提交 id):

curl --header "PRIVATE-TOKEN: ********" "https://gitlab.example.com/api/v4/projects/1/pipelines/latest"

{"id":442495,"sha":"e6b81550c9251b88a273ba6c86938769a76f9d15","ref":"master","status":"success","created_at":"2021-01-21T09:15:09.290+03:00","updated_at":"2021-01-21T09:15:27.869+03:00","web_url":"https://gitlab.example.com/ci/testproject/-/pipelines/442495","before_sha":"0000000000000000000000000000000000000000","tag":false,"yaml_errors":null,"user":{"id":369,"name":"John, Doe","username":"jdoe","state":"active","avatar_url":"****","web_url":"****","finished_at":"2021-01-21T09:15:27.857+03:00","committed_at":null,"duration":6,"coverage":null,"detailed_status":{"icon":"status_success","text":"passed","label":"passed","group":"success","tooltip":"passed","has_details":false,"details_path":"/ci/testproject/-/pipelines/123456","illustration":null,"favicon":"/assets/ci_favicons/favicon_status_success-8451333011eee8ce9f2ab25dc487fe24a8758c694827a582f17f42b0a90446a2.png"}}

at completed result we should get all text included in commits comments在完成的结果中,我们应该得到提交评论中包含的所有文本

Gitlab has a Commits API that you can use to get all commits in a project, or retrieve a single commit from it's sha. Gitlab 有一个提交 API,您可以使用它来获取项目中的所有提交,或从它的 sha 中检索单个提交。 For your use case, after you get the commits for the pipeline, you can run each one through the "get single commit" API to get the title/message (or any other part) as needed.对于您的用例,在获得管道的提交后,您可以通过“获取单个提交”API 运行每个提交,以根据需要获取标题/消息(或任何其他部分)。 You can also run the commit sha through the Commits Comments operation to get comments on that commit.您还可以通过 Commits Comments 操作运行提交 sha 以获取对该提交的评论。

The details for the Commits API and the Get Single Commit operation are here:https://docs.gitlab.com/ee/api/commits.html#get-a-single-commit提交 API 和 Get Single Commit 操作的详细信息在这里:https://docs.gitlab.com/ee/api/commits.html#get---s

The Commit Comments operation is here: https://docs.gitlab.com/ee/api/commits.html#get-the-comments-of-a-commit提交评论操作在这里: https://docs.gitlab.com/ee/api/commits.html#get-the-comments-of-a-commit

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM