Validate CODEOWNERS
Validates the first CODEOWNERS file in GitLab's supported precedence (CODEOWNERS, docs/CODEOWNERS, then .gitlab/CODEOWNERS). The job checks GitLab syntax, verifies that path patterns match tracked files, and confirms that referenced users, groups, group aliases, email addresses, and role owners are eligible for the project.
The component uses GitLab's API so validation matches the selected protected branch or tag. Store a token with read_api scope in a protected, masked CI/CD variable named GITLAB_TOKEN. The token must be able to read the project, its eligible users and groups, and member email addresses when email owners are used.
include:
- component: $CI_SERVER_FQDN/xrow-public/ci-tools/common@stable
- component: $CI_SERVER_FQDN/xrow-public/ci-tools/validate-codeowners@stable
The default rules run only on protected refs where the protected token is available. To use a differently named token variable:
include:
- component: $CI_SERVER_FQDN/xrow-public/ci-tools/validate-codeowners@stable
inputs:
token-variable: CODEOWNERS_READ_TOKEN
Set path to validate an explicit location, or set check-paths: false when intentionally declaring ownership for files that do not exist yet.
Inputs
| Name | Description | Default | Type |
| --- | --- | --- | --- |
| check-paths | Require every non-exclusion CODEOWNERS path pattern to match a tracked file. | true | boolean |
| name | Name of the CODEOWNERS validation job. | project | string |
| needs | Jobs required before validation. | [] | array |
| path | Explicit CODEOWNERS path. Empty selects GitLab's supported path precedence. | string | |
| ref | Repository branch or tag containing the CODEOWNERS file. | $CI_COMMIT_REF_NAME | string |
| rules | Rules controlling when CODEOWNERS validation runs. | [{"if":"$CI_COMMIT_REF_PROTECTED == \"true\"","when":"on_success"}] | array |
| stage | Stage where CODEOWNERS validation runs. | lint | string |
| tags | Runner tags for the validation job. | [] | array |
| timeout | GitLab API timeout in seconds. | 30 | number |
| token-variable | Protected CI/CD variable containing a GitLab token with read_api scope. | GITLAB_TOKEN | string |