Configuring 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 will be automatically converted to a link.

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 in the Links page. To create a custom rule, you can either copy an existing link rule or create a blank rule. For more information bout RegExp, see http://www.regular-expressions.info.

Creating a Link Rule

To create a link rule, you would need to define the RegExp pattern of the link text and the URL where the link would point to.

To create a link rule:
  1. In the navigation bar, click Project Settings.
  2. Click Links.
  3. To create a blank rule, click + New Link.
    To copy an existing rule, select the rule in the left list, and click + Copy Link.
  4. In the Custom Link section of the Create Link page, enter a name, link rule pattern (uisng RegExp), and the URL of the link with parameters.
    In the 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.

    If you have copied a link rule, edit the pattern and URL of the copied rule.

  5. In the Test section, test the rule. In Test Value, enter a value and verify its result in Test Result.
  6. After you are satisfied with the test result, click Done.
The link rule appears on the left list of the Links page. By default, the Links are listed in the priority order. You can use the drag-and-drop action to reorder them.

The following illustration shows an example of a custom link rule.

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

Editing a Link Rule

Click the link rule in the left list of the Links page to edit it.

Note:

You cannot edit a built-in link rule. You may create a copy of built-in rule and edit it, and if required, disable the original pre-configured rule.
  1. In the navigation bar, click Project Settings.
  2. Click Links.
  3. In the link rule list on the left, click the rule to view its details on the right.
  4. Edit the fields on the right. For more information about the fields, see Creating a Link Rule.
  5. Open another link rule or navigate to a different page to save the rule.

Activating or Deactivating a Link Rule

Open the link rule in the edit mode to activate or deactivate it. If deactivated, the text that matches the rule is not converted to a link.

To activate or deactivate a link rule:
  1. In the navigation bar, click Project Settings.
  2. Click Links.
  3. In the link rule list on the left, click the rule to view its details on the right.
  4. Click the Activate or the Deactivate button to activate or deactivate the rule.
    You can also select or deselect the Active check box.

Deleting a Link Rule

Open the link rule in the edit mode to delete it. You cannot delete a built-in link rule.

To delete a link rule:
  1. In the navigation bar, click Project Settings.
  2. Click Links.
  3. In the link rule list on the left, click the rule to view its details on the right.
  4. On the right side of the page, click the Delete button.