Configure Link Rules

In a project, you can define rules to convert plain text to URL links automatically when the text is entered in commit comments and merge request comments. For example, when you enter an email address or a URL in a merge request comment, it’s automatically converted to a link.

To configure link rules, follow these steps:

  1. In the left navigator, click Project Administration Project Administration.
  2. Click Links.

From the Links page, you can create and manage link rules that convert plain text to URL links automatically. You can use Regular Expressions, also called as RegExp, to define the link rules. Some pre-defined built-in link rules are available on the Links page. To create a custom rule, you can either copy an existing link rule or create a blank rule. To find more about RegExp, see http://www.regular-expressions.info.

This illustration shows an example of a custom link rule.

This illustration shows an example of the link in a merge request comment.

Action How To

Create a link rule

  1. On the Links page, click + Create Link.
  2. In Name, enter a name.
  3. In Pattern, enter the RegExp link rule pattern.
  4. In URL, enter the link URL.
    You can also use placeholders:
    • Use {project} to insert the project ID.
    • Use {organization} to insert the organization ID.
    • Use $& to insert the entire matching text, or use $1, $2, $3, and so on to insert text of matched groups. For more information, see http://www.regular-expressions.info/brackets.html.
  5. To test the rule, expand Test and Test Value, enter a test value. Verify the result link in Test Result.
  6. Click Done.

Copy a link rule

  1. On the Links page, click + Copy Link.
  2. On the Create Link page, edit the name, RegExp link rule pattern, and the URL of the link with parameters.
    You can also use placeholders:
    • Use {project} to insert the project ID.

    • Use {organization} to insert the organization ID.

    • Use $& to insert the entire matching text, or use $1, $2, $3, and so on to insert text of matched groups. For more information, see http://www.regular-expressions.info/brackets.html.

  3. To test the rule, expand Test and Test Value, enter a test value. Verify the result link in Test Result.
  4. To test the rule, in the Test section, click Test Value. Enter a value and verify its result in Test Result.
  5. Click Done.

Edit a link rule

You can’t edit a built-in link rule. You can create a copy of built-in rule and edit it, and if required, disable the original pre-configured rule.

On the Links page, in the link rule list on the left, select the rule to edit its details on the right.

Activate or deactivate a link rule

If deactivated, the text that matches the rule is not converted to a link.

On the Links page, in the link rule list on the left, select the rule. Click Activate or Deactivate. You can also select or deselect the Active check box.

Delete a link rule

You can’t delete a built-in rule.

On the Links page, in the link rule list on the left, select the rule. On the right side of the page, click Delete.