Skip to content

FMT-1

Script is not formatted correctly

Cause

The script does not match the output of shfmt. gitlab-ci-verify formats the script in memory and reports every hunk that differs from your script.

The finding message shows both versions of the affected lines, quoted with escapes:

[build:script:1] script is not formatted correctly, expected "echo    hi\n" -> "echo hi\n"

The check only runs with the --shfmt flag.

Formatting options come from the shellformat section of the config file. Without a config file, shfmt defaults apply, for example tab indentation.

Scripts with $[[ inputs.* ]] interpolations are not checked, because GitLab rewrites them before the script runs.

Fix

Format the script with the same options you configured:

shfmt -w your-script.sh

For scripts inside .gitlab-ci.yml, apply the change from the finding message, or use the shfmt options that match your team style and set them in the config file:

shellformat:
  indent: 2

Further information