The image is for running jsonlint, jsonlint is installed in /app/ in case you need to customize the install before usage. The image is based on node:10.14-alpine
jsonlint:
stage: linting
image: registry.gitlab.com/pipeline-components/jsonlint:latest
script:
- |
find . -not -path './.git/*' -name '*.json' -type f -print0 |
parallel --will-cite -k -0 -n1 jsonlint -q
pipeline {
agent none
stages {
// Perform JSON linting against files in ./folder_containing_json_files
// FAIL the build if linting does not pass
stage('Linting'){
agent {
docker {
image 'pipelinecomponents/jsonlint:latest'
registryUrl 'REDACTED'
args '-v "/$(pwd)/folder_containing_json_files":/code'
}
}
steps {
// Emits complete command to be run on each invocation of xargs via -t option
// Exits with code '123' upon linting failure
sh "find . -name \'*.json\' -type f | xargs -t -n 1 jsonlint -q"
}
}
...
}
}