Skip to content

swellaby/azdo-shellcheck

Repository files navigation

azdo-shellcheck

ShellCheck extension for Azure DevOps.

Functional, but still in an early preview/beta.

Version Badge Installs Badge Rating Badge License Badge

Linux CI Badge Mac CI Badge Windows CI Badge

Test Results Badge Coverage Badge

Contents

This extension adds two Azure Pipelines tasks to enable the execution of ShellCheck in your Pipelines.

  • Install ShellCheck - Use this task to install ShellCheck if your target agent does not already have ShellCheck installed (like the Hosted Agents)
  • Run ShellCheck - Use this task to run a ShellCheck analysis

Usage

Install Task

The install ShellCheck task only has a single input:

  • version - Specify the version of ShellCheck you want to install.
    • Input type: picklist
    • Default value: latest
    • Allowed values: latest, stable, 0.6.0, 0.5.0, 0.4.7, 0.4.6

Here's the task in a visual designer based pipeline:

And here's the snippet you'd use for a yaml based pipeline:

- task: swellaby.shellcheck.install-shellcheck.install-shellcheck@0
  displayName: 'Install ShellCheck'
  inputs:
    version: stable

Run Task

The run ShellCheck task has several inputs that map to various options/arguments to pass to ShellCheck. Please note that some options are only available in newer versions of ShellCheck.

Inputs:

  • targetFiles - The files to run the ShellCheck scan against. Note that you can use glob/wildcard patterns (with directory recursion). For visual designer based pipelines you also have the option to use the file picker.
    • Input type: filePath
    • Default value: **/*.sh
  • followSourcedFiles - Enable this option to follow source statements. When this input is set to true, the -x/--external-sources option will be passed to ShellCheck. Review the ShellCheck documentation on this option for more information.
    • Input type: boolean
    • Default value: false
  • checkSourcedFiles - Enable this option to report issues found in sourced files. When this input is set to true, the -a/--check-sourced option will be passed to ShellCheck. Review the ShellCheck documentation on this option for more information.
    • Input type: boolean
    • Default value: false
  • ignoredErrorCodes - Use this option to ignore specific error codes. Place each error code that should be ignored on a separate line in your pipeline config. When specified, this input will pass the -e option to ShellCheck with the specified error codes. Review the ShellCheck documentation on this option for more information.
    • Input type: multiline
  • outputFormat - This option specifies the type of output format to use. Review the ShellCheck documentation on this option for more information.
    • Input type: picklist
    • Default value: tty
    • Allowed values: tty, checkstyle, gcc, json
  • shellDialect - This option specifies the type of shell dialect to use. When this input is changed to something other than default, the -s option will be passed to ShellCheck with the specified dialect. Review the ShellCheck documentation on this option for more information.
    • Input type: picklist
    • Default value: default
    • Allowed values: default, sh, bash, dash, ksh
  • useRcFiles - Disable this option to ignore all ShellCheck rc files. When this input is set to false, the --norc option will be passed to ShellCheck. Review the ShellCheck documentation on this option for more information.
    • Input type: boolean
    • Default value: true

Here's the task in a visual designer based pipeline:

And here's the snippet you'd use for a yaml based pipeline:

- task: swellaby.shellcheck.shellcheck.shellcheck@0
  displayName: 'Run ShellCheck analysis'
  inputs:
    targetFiles: '**/*.sh'
    followSourcedFiles: true
    checkSourcedFiles: true
    ignoredErrorCodes: |
      SC2059
      SC2058
    outputFormat: checkstyle
    shellDialect: sh
    useRcFiles: false

Feedback and Contributing

We'd love to hear from you! Have a request, question, or found a bug? Let us know:

You can also add a review, and/or give us a star on GitHub!

Check out our contributing guide for detailed information on contributing to this extension.

Icon Credits

The task and extension icons were sourced from the shellcheck.net icon in https://github.com/koalaman/shellcheck.net