Using the "Run Command Line" action to run as another user (example: user1), and setup on the remote machine to use sudo, an error is returned about the command/script not being found. But the command executes successfully when manually connecting via ssh as user1.
Release Automation 5.x.x - 6.x.x
The problem is related to the profiles loaded for a user when using sudo. If you login via ssh as user1 and run the command "env" and then login via ssh as user2 and run: sudo -u user1 env
then you will notice that the outputs are not the same. The use of sudo is why.
1. You can use the Environment Variables Names and Environment Variables Values fields in the "Run Command Line" action to update the necessary environment variables to get your action to work; or
2. You can load the necessary profile(s) before running your command by doing something like this: sh /home/<username>/.bashrc; cat /tmp/test.txt
The semi-colon acts as a terminator between commands. So first it loads the profile and then it runs the command you want to run.