A basic docker image based off of Microsoft's PowerShell image which includes PSScriptAnalyzer
PSScriptAnalzyer-Docker can be pulled from either DockerHub:
docker pull docker.io/cypher0n3/psscriptanalyzer-docker
or GitLab:
docker pull registry.gitlab.com/cypher_zero/psscriptanalyzer-docker
The latest tag is always the latest, hopefully stable, build. This tag is updated automatically every Monday based on the latest PowerShell container and stable PSScriptAnalyzer.
If the pipeline status above indicates a failure, then this image is unstable.
These tags are known stable builds as tested by the developer. These correspond to the same tag name in the code repository. Identifying numbers correspond to the date the tag was created.
Numbered tags correspond to GitLab CI pipeline IIDs and should be considered development builds. Use at your own risk.
For advanced usage of PSScriptAnalyzer modules (Invoke-ScriptAnalyzer
) see: https://github.com/PowerShell/PSScriptAnalyzer.
Assuming you have a directory named test
in your local path which contains the scripts to test:
docker run -v ./test:/test cypher0n3/psscriptanalyzer-docker:latest "Invoke-ScriptAnalyzer -Path /test/*.ps1"
When running in a GitLab pipeline, override the default entry point and call pwsh -c Invoke-ScriptAnalyzer
as part of the script
block.
This is due to the way that GitLab sets up the container, etc.
See below for a working example:
psscriptanalyzer:
image:
name: registry.gitlab.com/cypher_zero/psscriptanalyzer-docker:latest
entrypoint: ["/bin/bash", "-c"]
variables:
PS1_TESTPATH: ./test/*.ps1
script:
- output=$(pwsh -c "Invoke-ScriptAnalyzer -Path $PS1_TESTPATH")
- echo "${output}"
- |
if [[ -n ${output} ]]; then
echo "Failures detected; see above."
exit 1
fi
Code and pipeline automation for this project is maintained in GitLab here: https://gitlab.com/cypher_zero/psscriptanalyzer-docker
Please submit all issues and merge requests via the above GitLab project. Submissions and issues from other sources (e.g. GitHub) will not be addressed.