Nosana Validate Pipeline Schema
Simple to use library to validate Nosana Pipeline Schemas.
You can learn more about the pipeline at Nosana Pipeline documentation.
The schema can be found at src/schema.ts.
When this library is bundled as ESM, types are also included.
Quickstart
Install:
npm i @nosana-ci/schema-validator
There are two functions available for use:
Example:
Validate JSON
import { validateJson } from '@nosana-ci/schema-validator'
const nosana_pipeline = {
"nosana": {
"description": "Run Test"
},
"global": {
"image": "registry.hub.docker.com/library/node:16",
"trigger": {
"branch": [
"main"
]
}
},
"jobs": [
{
"name": "install-deps and run test",
"commands": [
"npm ci",
"npm run test"
]
}
]
}
validateJson(nosana_pipeline)
Validate YAML
It is also possible to validate a YAML file:
const yaml = `
nosana:
description: Nosana-Node Pipeline
global:
image: registry.hub.docker.com/library/cljkondo/clj-kondo
trigger:
branch:
- main
environment:
DEBIAN_FRONTEND: noninteractive
jobs:
- name: install and build container
commands:
- env
- clj-kondo --lint src --dependencies --parallel --copy-configs
- git submodule init
- git submodule update
`
validateYaml(yaml)
Errors
If the schema is invalid, the errors will be returned.
The instancePath
will be the path to the invalid property and the message
will be the reason why it is invalid.
const nosana_pipeline = {
"nosana": {
"description": "Run Test"
},
"global": {
"image": "registry.hub.docker.com/library/node:16",
"trigger": {
"branch": [
"main"
]
}
},
"jobs": [
{
"name": "install-deps and run test",
"commands": [
"npm ci",
"npm run test"
]
}
]
}
validateJson(nosana_pipeline)