JSON lint component
This component uses AJV to lint discovered JSON files and can validate them against a local or remote JSON schema. The shared file finder accepts configurable file-name patterns and gitignore-style exclusion files.
Usage
Lint JSON files
- Create a new pipeline file
include:
- component: $CI_SERVER_FQDN/xrow-public/ci-tools/common@stable
- component: $CI_SERVER_FQDN/xrow-public/ci-tools/lint-json@stable
AJV applies a permissive schema during linting, so arbitrary JSON values are
accepted while malformed JSON fails the job. By default, the finder searches for
*.json below path and honors .gitignore and .jsonignore. The job succeeds
when no matching files exist.
Validate files against a schema
Set schema to a local JSON, JSON5, YAML, or CommonJS schema file. All files
selected by path, patterns, and ignore-from-file are validated.
include:
- component: $CI_SERVER_FQDN/xrow-public/ci-tools/common@stable
- component: $CI_SERVER_FQDN/xrow-public/ci-tools/lint-json@stable
inputs:
schema: schemas/application.json
path: config
patterns:
- "*.json"
ignore-from-file:
- .gitignore
- .jsonignore
Use an HTTP(S) URL to load a JSON schema:
include:
- component: $CI_SERVER_FQDN/xrow-public/ci-tools/lint-json@stable
inputs:
schema: https://json.schemastore.org/chart.json
path: chart
patterns:
- Chart.yaml
Schema validation is skipped when schema is empty.
Inputs
| Name | Description | Default | Type |
| --- | --- | --- | --- |
| allow-failure | Should the pipeline fail if the test fails? | false | boolean |
| ignore-from-file | Gitignore-style files used to exclude discovered files. | [".gitignore",".jsonignore"] | array |
| path | Root directory searched for files to lint. | . | string |
| patterns | File name patterns passed to the shared file finder. | ["*.json"] | array |
| schema | Local schema path or HTTP(S) schema URL. Empty disables schema validation. | string |