Skip to main content

YAML lint component

This component manages linting of YAML files. By default this component applies a configuration with reasonable settings for software projects.

Usage​

Example with one custom setting​

  • 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-yaml@stable
---
extends: default

Validate files against a schema​

Set schema to a local JSON, JSON5, YAML, or CommonJS schema file. The shared finder passes every file selected by path, patterns, and ignore-from-file to both yamllint and AJV.

include:
- component: $CI_SERVER_FQDN/xrow-public/ci-tools/common@stable
- component: $CI_SERVER_FQDN/xrow-public/ci-tools/lint-yaml@stable
inputs:
schema: schemas/helm.json
path: chart
patterns:
- Chart.yaml
- values.yaml
ignore-from-file:
- .gitignore
- .yamlignore

schema can also be an HTTP(S) URL that returns a JSON schema. Schema validation is skipped when schema is empty.

Inputs​

NameDescriptionDefaultType
------------
allow-failureShould the pipeline fail if the test fails?trueboolean
config-fileThe contents of the configuration file, if none exists.--- extends: default ignore: - '**/templates/**' - '**/node_modules/**' - 'release/**' rules: indentation: level: warning line-length: level: warning document-start: level: warning new-line-at-end-of-file: level: warning string
config-file-pathThe path of the configuration file..yamllint.yamlstring
ignore-from-fileGitignore-style files used to exclude discovered files.[".gitignore",".yamlignore"]array
optsThe options to pass to yamllint.string
pathThe path to lint..string
patternsFile name patterns passed to the shared file finder.["*.yaml","*.yml"]array
rulesThe rules that this job depends on.[{"if":"$CI_PIPELINE_SOURCE == \"schedule\"","when":"never"},{"exists":["**/*.yaml","**/*.yml"],"when":"on_success"},{"when":"never"}]array
schemaLocal schema path or HTTP(S) schema URL. Empty disables schema validation.string