Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Gitlab merge request description in Gitlab CI?

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

like image 598
sidshrivastav Avatar asked Jun 26 '26 00:06

sidshrivastav


2 Answers

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
like image 110
AmirMohammad Dadkhah Avatar answered Jun 28 '26 19:06

AmirMohammad Dadkhah


Looks like CI_MERGE_REQUEST_DESCRIPTION was just added apart of GitLab version 16.7

like image 45
Matt C Avatar answered Jun 28 '26 19:06

Matt C