Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dehasi/jenkins-pipeline-linter-gradle-plugin

Gradle plugin to validate Jenkins pipelines.
https://github.com/dehasi/jenkins-pipeline-linter-gradle-plugin

gradle-plugin jenkins-pipeline linter

Last synced: about 1 month ago
JSON representation

Gradle plugin to validate Jenkins pipelines.

Awesome Lists containing this project

README

        

= Jenkins Pipeline Linter Gradle Plugin

image:https://maven-badges.herokuapp.com/maven-central/me.dehasi/jenkins-pipeline-linter-gradle-plugin/badge.svg[link="https://maven-badges.herokuapp.com/maven-central/me.dehasi/jenkins-pipeline-linter-gradle-plugin"]
image:https://img.shields.io/github/license/dehasi/jenkins-pipeline-linter-gradle-plugin?color=blue&label=licence[GitHub]

Gradle plugin to validate Jenkins pipelines. It uses Jenkins https://www.jenkins.io/doc/book/pipeline/development/#linter[linter] and sends files by HTTP POST. To validate pipeline, Jenkins `pipeline-model-definition` plugin needs to be installed.

== Example
.gradle.build
[source, groovy]
----
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}'
}
}
----

== Run
[source, shell script]
----
$ 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
----