Skip to main content

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

NameDescriptionDefaultType
------------
check-pathsRequire every non-exclusion CODEOWNERS path pattern to match a tracked file.trueboolean
nameName of the CODEOWNERS validation job.projectstring
needsJobs required before validation.[]array
pathExplicit CODEOWNERS path. Empty selects GitLab's supported path precedence.string
refRepository branch or tag containing the CODEOWNERS file.$CI_COMMIT_REF_NAMEstring
rulesRules controlling when CODEOWNERS validation runs.[{"if":"$CI_COMMIT_REF_PROTECTED == \"true\"","when":"on_success"}]array
stageStage where CODEOWNERS validation runs.lintstring
tagsRunner tags for the validation job.[]array
timeoutGitLab API timeout in seconds.30number
token-variableProtected CI/CD variable containing a GitLab token with read_api scope.GITLAB_TOKENstring