Karlovsky120
Karlovsky120

Reputation: 6352

p4 describe command not working when executed in trigger

I have a trigger defined like this:

if [[ "$(p4 -Ztag -F %desc% describe -s $1 2>&1)" =~ ^(\[(Misc|Bug-Dev|Bug-Live|Feature|Public)\])+\ [a-zA-Z0-9]+.* ]]
then
    exit 0
else
    echo $1
    echo $(p4 -Ztag -F %desc% describe -s $1 2>&1)
    echo "Nothing"
    echo " Invalid commit message"
    echo " Expected commit message format:"
    echo "  [Type] Message"
    echo " where there can be multiple tags of Type:"
    echo "  Misc|Bug-Dev|Bug-Live|Feature|Public"
    exit 1
fi

Running command p4 -Ztag -F %desc% describe -s $1 2>&1 on my local machine works without issues, I get the submit message.

However, if I try to submit anything, I get the following result:

enter image description here

Notice that the line where the output of echo $(p4 -Ztag -F %desc% describe -s $1 2>&1) would go is empty.

What is going on here?

Upvotes: 0

Views: 52

Answers (1)

Karlovsky120
Karlovsky120

Reputation: 6352

The problem was that the user that was executing the script on the p4 server didn't have access to p4. Yep.

The fix was to put this at the start of the file:

export P4PORT=ssl:p4.server.url:1666
export P4USER=username

Note that the server uses SSO, so that's probably a part of the problem.

Upvotes: 0

Related Questions