Gradle plugin to validate Jenkins pipelines. It uses Jenkins linter and sends files by HTTP POST. To validate pipeline, Jenkins pipeline-model-definition
plugin needs to be installed.
gradle.build
import static me.dehasi.jenkins.linter.LinterExtension.ActionOnFailure.FAIL_BUILD
plugins {
id 'me.dehasi.jenkins-pipeline-linter' version '${VERSION}'
}
jenkinsPipelineLinter {
pipelinePath = ['path/to/jenkinsfile1', 'path/to/jenkinsfile2']
actionOnFailure = FAIL_BUILD // or WARNING
jenkins {
url = 'https://jenkins.example'
ignoreCertificate()
username = '${USERNAME}'
password = '${PASSWORD}'
}
}
$ gradle lint
> Task :lint FAILED
Validating 2 files
Validating '/**/path/to/jenkinsfile1'
Jenkinsfile successfully validated.
Validating '/**/path/to/jenkinsfile2'
Errors encountered validating Jenkinsfile:
WorkflowScript: 2: Not a valid section definition: "agent". Some extra configuration is required. @ line 2, column 3.
agent
^
WorkflowScript: 1: Missing required section "agent" @ line 1, column 1.
pipeline {
^
Validation finished with 1 errors.
FAILURE: Build failed with an exception.
BUILD FAILED in 705ms