Skip to content

Commit

Permalink
Support Sonarqube as output formatter
Browse files Browse the repository at this point in the history
In Hadolint `2.5.0` the sonarqube formatter was added.
This allows us to output it as part of running CI.
  • Loading branch information
jbergstroem committed Jun 15, 2021
1 parent eb931d4 commit 5e9865c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ jobs:
## Parameters
| Variable | Default | Description |
| :------------ | :------------- | :---------------------------------------------------------------------------------------------------- |
| dockerfile | `./Dockerfile` | Path to Dockerfile(s). Accepts shell expansions (`**/Dockerfile`) |
| config_file | | Path to optional config (hadolint defaults to read `./hadolint.yml` if it exists) |
| error_level | `0` | Fail CI if hadolint emits output (`-1`: never, `0`: error, `1`: warning, `2`: info) |
| annotate | true | Annotate code inline in the github PR viewer (`true`/`false`) |
| output_format | | Set output format (choose between `tty`, `json`, `checkstyle`, `codeclimate` or `gitlab_codeclimate`) |
| hadolint_path | | Absolute path to hadolint binary. If unset, it is assumed to exist in `$PATH` |
| Variable | Default | Description |
| :------------ | :------------- | :----------------------------------------------------------------------------------------------------------------- |
| dockerfile | `./Dockerfile` | Path to Dockerfile(s). Accepts shell expansions (`**/Dockerfile`) |
| config_file | | Path to optional config (hadolint defaults to read `./hadolint.yml` if it exists) |
| error_level | `0` | Fail CI if hadolint emits output (`-1`: never, `0`: error, `1`: warning, `2`: info) |
| annotate | true | Annotate code inline in the github PR viewer (`true`/`false`) |
| output_format | | Set output format (choose between `tty`, `json`, `checkstyle`, `codeclimate`, `gitlab_codeclimate` or `sonarqube`) |
| hadolint_path | | Absolute path to hadolint binary. If unset, it is assumed to exist in `$PATH` |

## Hadolint version

Expand Down
2 changes: 1 addition & 1 deletion lib/validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function validate_annotate() {
}

function validate_output_format() {
local -a output_formats=(tty json checkstyle codeclimate gitlab_codeclimate)
local -a output_formats=(tty json checkstyle codeclimate gitlab_codeclimate sonarqube)
for format in "${output_formats[@]}"; do
[[ "${format}" == "${1}" ]] && return 0
done
Expand Down
1 change: 1 addition & 0 deletions test/unit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ test_validate_invalid_annotate() {
test_validate_output_format() {
assert "validate_output_format gitlab_codeclimate"
assert "validate_output_format tty"
assert "validate_output_format sonarqube"
}

test_validate_invalid_output_format() {
Expand Down

0 comments on commit 5e9865c

Please sign in to comment.