GithubHelp home page GithubHelp logo

azdo-inline-script-shellcheck's Introduction

Pre-commit hook for performing Shellcheck on shell snippets in AZDO pipeline yamls

This pre-commit hook performs shellcheck on script tasks in Azure Devops pipeline yaml files.

validate-shell-snippets

The validate shell snippets hook extracts (bash) shell script snippets from AZDO pipeline yaml files. Shellcheck is executed for each snippet encountered.

AZDO parameter or variable references (with the ${{ par }} syntax) are converted into shell variabel references to prevent errors. The Shellcheck is configured to ignore SC2154 since these variables are provided from outside the script snippets.

Usage

In your .pre-commit-config.yaml use the following config:

- repo: https://github.com/krisgeus/azdo-inline-script-shellcheck
  rev: v2.0.2
  hooks:
  - id: validate-shell-snippets
    name: Check shell snippets in yaml files
    language: docker
    entry: /bin/validate-shell-snippets

validate-shell-snippets-docker-latest

Same as Validate Shell Snippets but using the pre-built docker image (tag latest)

validate-shell-snippets-docker-latest Usage

In your .pre-commit-config.yaml use the following config:

- repo: https://github.com/krisgeus/azdo-inline-script-shellcheck
  rev: v2.0.2
  hooks:
  - id: validate-shell-snippets-docker-latest
    name: Check shell snippets in yaml files

validate-shell-snippets-docker-release

Same as Validate Shell Snippets but using the pre-built docker image from the release (tag v2.0.2)

validate-shell-snippets-docker-release Usage

In your .pre-commit-config.yaml use the following config:

- repo: https://github.com/krisgeus/azdo-inline-script-shellcheck
  rev: v2.0.2
  hooks:
  - id: validate-shell-snippets-docker-release
    name: Check shell snippets in yaml files

validate-powershell-snippets

The validate powershell snippets hook extracts (pwsh) shell script snippets from AZDO pipeline yaml files. PSScriptAnalyzer is executed for each snippet encountered.

AZDO parameter or variable references (with the ${{ par }} syntax) are converted into powershell variabel references to prevent errors.

Powershell validation Usage

In your .pre-commit-config.yaml use the following config:

- repo: https://github.com/krisgeus/azdo-inline-script-shellcheck
  rev: v2.0.2
  hooks:
  - id: validate-powershell-snippets
    name: Check powershell snippets in yaml files
    language: docker
    entry: /bin/validate-pwsh-snippets

validate-powershell-snippets-docker-latest

The validate Powershell snippets hook extracts powershell script snippets from AZDO pipeline yaml files. PSScriptAnalyzer is executed for each snippet encountered.

AZDO parameter or variable references (with the ${{ par }} syntax) are converted into powershell variabel references to prevent errors.

The hook is using the pre-built docker image (tag latest)

validate-powershell-snippets-docker-latest Usage

In your .pre-commit-config.yaml use the following config:

- repo: https://github.com/krisgeus/azdo-inline-script-shellcheck
  rev: v2.0.2
  hooks:
  - id: validate-powershell-snippets-docker-latest
    name: Check shell snippets in yaml files

validate-powershell-snippets-docker-release

Same as Validate Powershell Snippets but using the pre-built docker image from the release (tag v2.0.2)

validate-powershell-snippets-docker-release Usage

In your .pre-commit-config.yaml use the following config:

- repo: https://github.com/krisgeus/azdo-inline-script-shellcheck
  rev: v2.0.2
  hooks:
  - id: validate-powershell-snippets-docker-release
    name: Check shell snippets in yaml files

azdo-inline-script-shellcheck's People

Contributors

krisgeus avatar

Watchers

 avatar

azdo-inline-script-shellcheck's Issues

Invoke-analyzer module not available when running in pre-commit docker

Invoke-ScriptAnalyzer: /bin/analyze-pwsh-snippet.ps1:12
Line |
  12 |  Invoke-ScriptAnalyzer -ScriptDefinition $pwsh_snippet -EnableExit -Re …
     |  ~~~~~~~~~~~~~~~~~~~~~
     | The term 'Invoke-ScriptAnalyzer' is not recognized as a name of a
     | cmdlet, function, script file, or executable program. Check the spelling
     | of the name, or if a path was included, verify that the path is correct
     | and try again.

Command running: docker run -v ${PWD}:/src:rw,Z --user $(id -u):$(id -g) --workdir /src [ghcr.io/krisgeus/inline-pwsh-check:latest](http://ghcr.io/krisgeus/inline-pwsh-check:latest) deploy.yml

When running without the --user it works correctly.
I assume it is because the installed module is not available for all users somehow.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.