Skip to content

The Shellcheck Gradle plugin performs quality checks on your project’s shell source files using Shellcheck and generates reports from these checks.

License

Notifications You must be signed in to change notification settings

cnygardtw/gradle-shellcheck-plugin

 
 

Repository files navigation

The Shellcheck Plugin

The Shellcheck plugin performs quality checks on your project’s Shell source files using Shellcheck and generates reports from these checks.

Usage

To use the Shellcheck plugin, include the following in your build script:

plugins {
    id("com.felipefzdz.gradle.shellcheck") version "1.0.0"
}

The plugin adds a task to the project called shellcheck that performs the quality checks.

Note that in order to be portable and repeatable Shellcheck will run:

  • Through a Docker container

  • A configurable Shellcheck version

This implies that no dependencies are required on the executing machine, except for Docker itself.

Tasks

The Shellcheck plugin a task called shellcheck to the project.

Extension

shellcheck {
    sources = files("src/shellScripts", "src/moreScripts")
    isIgnoreFailures = true
    isShowViolations = true
    shellcheckVersion = "v0.7.1"
    severity = "error"
}
  • sources - Folders where the shell scripts are located. It will search recursively matching .sh, .bash, .bash_login, .bash_logout, .bash_profile, .bashrc and .ksh files. Matching on shell scripts with no extension is not supported yet.

  • isIgnoreFailures - Whether to allow the build to continue if there are warnings.

  • isShowViolations - Whether rule violations are to be displayed on the console. Defaults to true.

  • shellcheckVersion - By default "v0.7.1"

  • severity - Minimum severity of errors to consider (error, warning, info, style). Defaults to style.

Customizing the HTML report

The HTML report generated by the Shellcheck task can be customized using a XSLT stylesheet, for example to highlight specific errors or change its appearance:

tasks.withType<Shellcheck>().configureEach {
    reports {
        xml.isEnabled = false
        txt.isEnabled = false
        html.isEnabled = true
        html.stylesheet = resources.text.fromFile("config/xsl/shellcheck-custom.xsl")
    }
}

XML generated report comes from shellcheck -f checkstyle, therefore you can get inspiration from a sample Checkstyle stylesheet.

TXT generated report comes from shellcheck -f tty.

About

The Shellcheck Gradle plugin performs quality checks on your project’s shell source files using Shellcheck and generates reports from these checks.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 56.2%
  • Groovy 20.4%
  • XSLT 15.6%
  • Kotlin 5.3%
  • Shell 2.5%