error trying to execute a command [script-executor] Script completed with exit code: 127.

150 views
Skip to first unread message

Sifu Tian

unread,
Dec 3, 2021, 10:44:48 PM12/3/21
to go-cd
Hi Everyone,

Ive been spinning my wheels trying to get my pipeline to run a straight forward salt-ssh command place in the script editor.

I've updated my .bashrc with the path export PATH=$PATH:/var/go/.local/bin
as this is where salt-ssh is installed however I still get an error 
/f835531d-e481-4e73-8770-bfb4950256fa.sh: line 2: salt-ssh: command not found
[script-executor] Script completed with exit code: 127.

When I run the command from the agent under the go user, it runs just fine:
-------------- Succeeded: 102 (changed=8) Failed: 0 -------------- Total states run: 102 Total run time: 9.241 s

Im not sure what Im doing wrong but any help would be greatly appreciated

Ashwanth Kumar

unread,
Dec 3, 2021, 11:04:29 PM12/3/21
to go...@googlegroups.com
A few things you can try:

1. Try adding the shebang for bash on your script. -- this will help ensure bash is the interpreter that's being used and it would pick up the .bashrc from go user. 
2. See if you can update the PATH on /etc/profile or a similar path so even sh sheel can pick it up. 
3. Try restarting the go-cd agents, for them to pick up the new environment variable values. 


--
You received this message because you are subscribed to the Google Groups "go-cd" group.
To unsubscribe from this group and stop receiving emails from it, send an email to go-cd+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/go-cd/9dabb32c-d43f-4acf-b892-116486832dbbn%40googlegroups.com.

Chad Wilson

unread,
Dec 4, 2021, 1:11:18 AM12/4/21
to go...@googlegroups.com
Hiya

When you run Bash from tools like GoCD it runs non-interactive, non-login shells so my understanding is that no files such as .bashrc are automatically loaded.

If you want to tell a task to load this automatically you could set BASH_ENV=/home/go/.bashrc (or to any other such init file) in the GoCD environment variables for any pipeline/stage/job. If you really want it to apply across all commands on the agent you could set BASH_ENV in the GoCD agent environment too and it would propagate to all tasks that agent runs.

-Chad

--

Sifu Tian

unread,
Dec 4, 2021, 8:56:48 PM12/4/21
to go-cd
Hi Chad,

Thanks,

I found the issue.  For some reason, even though I installed salt-ssh under the go user, I put in the pipeline script 
echo $USER
id $(echo $USER)
and it showed that the pipeline was running under the ubuntu user...which absolutely did not make any sense.
So I proceeded to do the install of salt-ssh again through the pipeline itself.

echo $USER
id $(echo $USER)
pip install salt-ssh==3002.6
export PATH=/var/go/.local/bin:$PATH
salt-ssh -V

After I received a successful pipeline for the commands above, I removed everthing and put my original salt-ssh command and it completed successfully.
I can't explain why it was running as ubuntu but it works now.

Sifu Tian

unread,
Dec 4, 2021, 9:09:54 PM12/4/21
to go-cd

Actually,

I tested on another pipeline and all I needed to do was add export PATH=/var/go/.local/bin:$PATH which fixed the issue.
Reply all
Reply to author
Forward
0 new messages