2020-10-24 23:57:45 +05:30
---
stage: Create
2021-04-17 20:07:23 +05:30
group: Code Review
2022-11-25 23:54:43 +05:30
info: "To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments"
2020-10-24 23:57:45 +05:30
type: reference
---
2021-03-11 19:13:27 +05:30
# Issue closing pattern **(FREE SELF)**
2016-09-29 09:46:39 +05:30
2021-02-22 17:27:13 +05:30
NOTE:
2019-12-04 20:38:33 +05:30
This is the administration documentation. There is a separate [user documentation ](../user/project/issues/managing_issues.md#closing-issues-automatically )
on issue closing pattern.
2016-09-29 09:46:39 +05:30
When a commit or merge request resolves one or more issues, it is possible to
2021-04-17 20:07:23 +05:30
automatically close these issues when the commit or merge request lands
2016-09-29 09:46:39 +05:30
in the project's default branch.
## Change the issue closing pattern
In order to change the pattern you need to have access to the server that GitLab
is installed on.
2021-09-04 01:27:46 +05:30
The default pattern can be located in [`gitlab.yml.example` ](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/gitlab.yml.example )
2019-12-04 20:38:33 +05:30
under the "Automatic issue closing" section.
2016-09-29 09:46:39 +05:30
2021-02-22 17:27:13 +05:30
NOTE:
2019-12-21 20:55:43 +05:30
You are advised to use < https: / / rubular . com > to test the issue closing pattern.
2016-09-29 09:46:39 +05:30
Because Rubular doesn't understand `%{issue_ref}` , you can replace this by
`#\d+` when testing your patterns, which matches only local issue references like `#123` .
**For Omnibus installations**
1. Open `/etc/gitlab/gitlab.rb` with your editor.
2018-05-09 12:01:36 +05:30
1. Change the value of `gitlab_rails['gitlab_issue_closing_pattern']` to a regular
2016-09-29 09:46:39 +05:30
expression of your liking:
2019-09-30 21:07:59 +05:30
```ruby
2021-04-17 20:07:23 +05:30
gitlab_rails['gitlab_issue_closing_pattern'] = /\b((?:[Cc]los(?:e[sd]?|ing)|\b[Ff]ix(?:e[sd]|ing)?|\b[Rr]esolv(?:e[sd]?|ing)|\b[Ii]mplement(?:s|ed|ing)?)(:?) +(?:(?:issues? +)?%{issue_ref}(?:(?: *,? +and +| * ,? *)?)|([A-Z][A-Z0-9_]+-\d+))+)/.source
2019-09-30 21:07:59 +05:30
```
2019-12-04 20:38:33 +05:30
1. [Reconfigure ](restart_gitlab.md#omnibus-gitlab-reconfigure ) GitLab for the changes to take effect.
2016-09-29 09:46:39 +05:30
**For installations from source**
1. Open `gitlab.yml` with your editor.
1. Change the value of `issue_closing_pattern` :
2019-09-30 21:07:59 +05:30
```yaml
2020-05-24 23:13:21 +05:30
issue_closing_pattern: "\b((?:[Cc]los(?:e[sd]?|ing)|\b[Ff]ix(?:e[sd]|ing)?|\b[Rr]esolv(?:e[sd]?|ing)|\b[Ii]mplement(?:s|ed|ing)?)(:?) +(?:(?:issues? +)?%{issue_ref}(?:(?: *,? +and +| * ,? *)?)|([A-Z][A-Z0-9_]+-\d+))+)"
2019-09-30 21:07:59 +05:30
```
2016-09-29 09:46:39 +05:30
2019-12-04 20:38:33 +05:30
1. [Restart ](restart_gitlab.md#installations-from-source ) GitLab for the changes to take effect.