2020-07-29 08:09:45 -04:00
---
stage: Create
2021-02-22 01:10:57 -05:00
group: Code Review
2020-11-26 01:09:20 -05:00
info: "To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments"
2020-07-29 08:09:45 -04:00
type: reference
---
2021-01-28 01:08:59 -05:00
# Issue closing pattern **(FREE SELF)**
2016-09-21 07:01:48 -04:00
2020-12-04 16:09:29 -05:00
NOTE:
2019-08-26 16:17:51 -04:00
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-21 07:01:48 -04:00
When a commit or merge request resolves one or more issues, it is possible to
2021-03-04 19:09:24 -05:00
automatically close these issues when the commit or merge request lands
2016-09-21 07:01:48 -04:00
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-06-08 14:10:23 -04:00
The default pattern can be located in [`gitlab.yml.example` ](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/gitlab.yml.example )
2019-08-26 16:17:51 -04:00
under the "Automatic issue closing" section.
2016-09-21 07:01:48 -04:00
2020-12-07 22:09:37 -05:00
NOTE:
2019-10-07 23:05:52 -04:00
You are advised to use < https: / / rubular . com > to test the issue closing pattern.
2016-09-21 07:01:48 -04:00
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-03-29 07:38:09 -04:00
1. Change the value of `gitlab_rails['gitlab_issue_closing_pattern']` to a regular
2016-09-21 07:01:48 -04:00
expression of your liking:
2019-07-09 03:16:17 -04:00
```ruby
2021-03-04 19:09:24 -05:00
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-07-09 03:16:17 -04:00
```
2019-08-26 16:17:51 -04:00
1. [Reconfigure ](restart_gitlab.md#omnibus-gitlab-reconfigure ) GitLab for the changes to take effect.
2016-09-21 07:01:48 -04:00
**For installations from source**
1. Open `gitlab.yml` with your editor.
1. Change the value of `issue_closing_pattern` :
2019-07-09 03:16:17 -04:00
```yaml
2020-04-21 11:21:10 -04:00
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-07-09 03:16:17 -04:00
```
2016-09-21 07:01:48 -04:00
2019-08-26 16:17:51 -04:00
1. [Restart ](restart_gitlab.md#installations-from-source ) GitLab for the changes to take effect.