Commit ddb3b834 authored by Ilya Vassilevsky's avatar Ilya Vassilevsky Committed by Marcel Amirault

Improve description of GitLab CI YAML `coverage` regex usage

parent 2f8de49d
...@@ -1321,12 +1321,14 @@ Use `coverage` with a custom regular expression to configure how code coverage ...@@ -1321,12 +1321,14 @@ Use `coverage` with a custom regular expression to configure how code coverage
is extracted from the job output. The coverage is shown in the UI if at least one is extracted from the job output. The coverage is shown in the UI if at least one
line in the job output matches the regular expression. line in the job output matches the regular expression.
To extract the code coverage value in the matching line, GitLab uses this To extract the code coverage value from the match, GitLab uses
regular expression: `\d+(\.\d+)?`. this smaller regular expression: `\d+(\.\d+)?`.
**Possible inputs**: **Possible inputs**:
- A regular expression. Must start and end with `/`. - A regular expression. Must start and end with `/`. Must match the coverage number.
May match surrounding text as well, so you don't need to use a regular expression character group
to capture the exact number.
**Example of `coverage`**: **Example of `coverage`**:
...@@ -1338,14 +1340,18 @@ job1: ...@@ -1338,14 +1340,18 @@ job1:
In this example: In this example:
1. GitLab checks the job log for a line that matches the regular expression. A line 1. GitLab checks the job log for a match with the regular expression. A line
like `Code coverage: 67.89` would match. like `Code coverage: 67.89% of lines covered` would match.
1. GitLab then checks the line to find a match to `\d+(\.\d+)?`. The sample matching 1. GitLab then checks the matched fragment to find a match to `\d+(\.\d+)?`.
line above gives a code coverage of `67.89`. The sample matching line above gives a code coverage of `67.89`.
**Additional details**: **Additional details**:
- If there is more than one matched line in the job output, the last line is used. - If there is more than one matched line in the job output, the last line is used
(the first result of reverse search).
- If there are multiple matches in a single line, the last match is searched
for the coverage number.
- If there are multiple coverage numbers found in the matched fragment, the first number is used.
- Leading zeros are removed. - Leading zeros are removed.
- Coverage output from [child pipelines](../pipelines/parent_child_pipelines.md) - Coverage output from [child pipelines](../pipelines/parent_child_pipelines.md)
is not recorded or displayed. Check [the related issue](https://gitlab.com/gitlab-org/gitlab/-/issues/280818) is not recorded or displayed. Check [the related issue](https://gitlab.com/gitlab-org/gitlab/-/issues/280818)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment