How to get Gitlab merge request description in Gitlab CI?

跟風遠走 提交于 2021-01-27 14:01:35

问题


I want to fetch the description of the merge request to generate changelog. Is it possible to get the description??


回答1:


In GitLab CI/CD's predefined environment variables there are some variables related to merge requests, such as:

CI_MERGE_REQUEST_ASSIGNEES
CI_MERGE_REQUEST_CHANGED_PAGE_PATHS
CI_MERGE_REQUEST_CHANGED_PAGE_URLS
CI_MERGE_REQUEST_ID
CI_MERGE_REQUEST_IID
CI_MERGE_REQUEST_LABELS
CI_MERGE_REQUEST_PROJECT_PATH
CI_MERGE_REQUEST_PROJECT_URL
CI_MERGE_REQUEST_REF_PATH
CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
CI_MERGE_REQUEST_SOURCE_BRANCH_SHA
CI_MERGE_REQUEST_SOURCE_PROJECT_ID
CI_MERGE_REQUEST_SOURCE_PROJECT_PATH
CI_MERGE_REQUEST_SOURCE_PROJECT_URL
CI_MERGE_REQUEST_TARGET_BRANCH_NAME
CI_MERGE_REQUEST_TARGET_BRANCH_SHA
CI_MERGE_REQUEST_TITLE
CI_MERGE_REQUEST_EVENT_TYPE

⋮

You can easily access them inside pipelines and jobs.


EDIT:
It seems there is no variable to access the merge requests description. I think using GitLab's Merge requests API can be helpful. So by requesting below URL inside your pipeline (using curl or other tools) you will get access to more information about a single merge request:

GET    $CI_API_V4_URL/projects/$CI_PROJECT_ID/merge_requests/$CI_MERGE_REQUEST_IID


来源:https://stackoverflow.com/questions/60769827/how-to-get-gitlab-merge-request-description-in-gitlab-ci

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!