GitLab API inside Job

I want to get MR description when running MR pipeline.
I only see MR Title variable available in the documentation.
The idea was to use gitlab API.
But the only way to use this api is to create personal access token and use this to authorise api server. How I can get this token (previously created in profile settings) inside pipeline, preferably via ci variables. As an option is to hardcode this as secure (hidden) variable for particular project. But This is not a good case, when I remove this token, so that I won’t be able to use this token, and I won’t understand why, until I discover that token expired/removed.
Any ideas how to get MR description inside pipeline job?
SaaS, free tier.

The description is available in the response to this API call

For the token, it would be sensible to add this as a project variable and mark it as masked so that it won’t appear in your pipeline logs.

thanks!
And is this a good practice to get suck kind of information about MR description, using personal access token inside pipeline job?

I think it’s fine, but do make sure you have the PAT masked in your CI variables, so that it doesn’t leak.

okay, thanks

1 Like

I would use project access token. They allow the same like personal access token, but are restricted to a project…

I suppose project access tokens are available only on paid tier.
I’m using gitlab free plan.

It is also available in the free plan- we are using it.

Regarding link you shared.
I can’t see any Access tokens menu item.
See my screenshot
Screenshot 2022-04-18 at 20.44.13

This feature was introduced in gitlab 13 behind a feature flag.
The feature flag was removed in gitlab 13.5.

Maybe you are using an older gitlab version?

Im on saas

Personal access tokens are very similar and available on all SASS tiers.