3

By default GitLab adds issue ID from branch name to the merge request description, see Merge requests to close issues:

Merge requests to close issues

To create a merge request to close an issue when it’s merged, you can either:

  • Add a note in the MR description.

  • In the issue, select Create a merge request. Then, you can either:

    • Create a new branch and a draft merge request in one action. The branch is named issuenumber-title by default, but you can choose any name, and GitLab verifies that it’s not already in use. The merge request inherits the milestone and labels of the issue, and is set to automatically close the issue when it is merged.
    • Create a new branch only, with its name starting with the issue number.

But I want to use a custom merge request description template, see Create a merge request template:

Create a merge request template

Similarly to issue templates, create a new Markdown (.md) file inside the .gitlab/merge_request_templates/ directory in your repository. Commit and push to your default branch.

Research

Question

How to add issue ID from branch name to the merge request description template?

dur
  • 15,689
  • 25
  • 79
  • 125
  • 1
    For now I don't think (or at least I don't know of) there is a built-in feature for that but, GitLab team is working on something that will make this possible. You can follow this [issue](https://gitlab.com/gitlab-org/gitlab/-/issues/18103) and the related issues/MRs... You can read [this](https://stackoverflow.com/questions/43743141/using-gitlab-variables-in-gitlab-readme-md-for-sonarqube-badges) too. – Iduoad Apr 01 '22 at 05:13
  • @Bosshoss No, I'm still waiting for the issue closed (see Iduoad's comment). – dur Mar 16 '23 at 20:11

1 Answers1

1

I'm looking for a similar problem, i see that Push Options can be a solution for this: https://docs.gitlab.com/ee/user/project/push_options.html for example:

merge_request.title="<title>" Set the title of the merge request.
merge_request.description="<description>" Set the description of the merge request.

It is true that this must be set up by the developer on the client side, but with git hooks and shell scripts, the content can be anything!

  • @desertnaut I don't understand what the problem is with my post: I don't have any new questions. I wrote an opportunity for the questioner! And I asked his opinion on whether it could be good for him. – Simon Benjámin Aug 30 '22 at 08:15
  • @desertnaut I seriously don't understand what the problem was with my answer. I edited it. That's good? – Simon Benjámin Aug 30 '22 at 15:23