I was only able to use this successfully after reading @NLKNguyen's instructions on his Docker hub page.
The key advice here is to mount the current working directory on /mnt, as in the very good instructions @NLKNguyen provided:
Use as CLI program
$ docker run --rm -it -v $(pwd):/mnt koalaman/shellcheck --version
# Only use TTY for Docker if we detect one, otherwise
# this will balk when run in Jenkins
# Thanks https://stackoverflow.com/a/48230089
declare USE_TTY
test -t 1 && USE_TTY="-t" || USE_TTY=""
# ...
function get_docker_shellcheck() {
# See https://hub.docker.com/r/nlknguyen/alpine-shellcheck/
# and https://github.com/koalaman/shellcheck/issues/727
echo "docker run --rm -i ${USE_TTY} -v $(pwd):/mnt koalaman/shellcheck"
}
This is still an issue, alas @koalaman & @NLKNguyen - could whoever controls the koalaman/shellcheck Docker hub page coordinate to improve it for usability?
The issue #727 brought in a lightweight
Dockerfile
that works really well. Thanks @koalaman and @NLKNguyen for getting this done.It would be super-nice if the lovely documentation explaining how to use the Docker container in the
nlknguyen/alpine-shellcheck
Docker hub page made it to thekoalaman/shellcheck
Docker hub page.I was only able to use this successfully after reading @NLKNguyen's instructions on his Docker hub page. The key advice here is to mount the current working directory on /mnt, as in the very good instructions @NLKNguyen provided:
Use as CLI program
But all of that documentation is really good and it would be great if it would get adapted and migrated to https://hub.docker.com/r/nlknguyen/alpine-shellcheck/
See This In Action
I was able to use this as part of a validation/linting script in https://github.com/ModusCreateOrg/devops-infra-demo that checks all the shell scripts for errors in CI. See the
Jenkinsfile
,bin/validate.sh
, andbin/common.sh
, where this gets used.From the
Jenkinsfile
:From
bin/common.sh
:From
bin/validate.sh
, :