Search code examples
githookbundlergithooksrbenv

Why is the git pre-receive hook not detecting puppet-lint?


I'm using the drwahl/puppet-git-hooks.

I have puppet-lint installed on my local machine however when I do my git push origin puppet_hook I get the following output:

Compressing objects: 100% (2/2), done.
Writing objects: 100% (4/4), 345 bytes | 0 bytes/s, done.
Total 4 (delta 1), reused 0 (delta 0)
remote: Checking puppet manifest syntax for manifests/init.pp...
remote: Error: Could not parse for environment production: Syntax error at '}' at manifests/init.pp:3
remote: Error: puppet syntax error in manifests/init.pp (see above)
remote: Error: 1 syntax error(s) found in puppet manifests. Commit will be aborted.
remote: puppet-lint not installed. Skipping puppet-lint tests...
remote: Error: 1 subhooks failed. Declining push.
remote: Hook /var/tmp/hooks/pre-receive.puppet failed with error code 1

As you can see it says:

remote: puppet-lint not installed. Skipping puppet-lint tests...

When I traced it to the pre-receive script (provided above) I found the following check:

 #puppet manifest styleguide compliance
        if [ "$CHECK_PUPPET_LINT" != "disabled" ] ; then
            if type puppet-lint >/dev/null 2>&1; then
                if [ $(echo $changedfile | grep -q '\.*.pp$' ; echo $?) -eq 0 ]; then
                    ${subhook_root}/puppet_lint_checks.sh $CHECK_PUPPET_LINT $tmpmodule "${tmptree}/"
                    RC=$?
                    if [ "$RC" -ne 0 ]; then
                        failures=`expr $failures + 1`
                    fi
                fi
            else
                echo "puppet-lint not installed. Skipping puppet-lint tests..."
            fi
        fi

It seems to be failing at:

if type puppet-lint >/dev/null 2>&1; then

When I run the above command locally it is successful.

Why is not detecting puppet-lint via the pre-receive script?


Solution

  • Check the server that you're going on to. The user that you're running this as may not have the alias set up, or have puppet-lint in the path.