I really need QB agent run bash on FreeBSD. So I created user 'qb' with the default shell 'bash'. I am running the agent as user 'qb'. One would think, all shell steps would be invoked with the user's default shell, i.e. bash. But that's not what happens.
This is for QB 15.0.9
I have this in agent.sh
RUN_AS_USER=qb
The agent does run as user qb:
[qb@qba7 ~/buildagent/bin]$ ps ux
USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
qb 22520 0.0 0.1 16764 4532 - S 01:21 0:00.99 /home/qb/buildagent/bin/./wrapper-freebsd-x86-64 /home/qb/buildagent/bin/../conf/wrapper.co
qb 22540 0.0 6.3 4066508 522264 - I 01:21 0:29.30 /usr/local/openjdk17-jre/bin/java -Djava.awt.headless=true -XX:+IgnoreUnrecognizedVMOptions
[...]
I then run a build with a single step containing a simple test for bash:
echo $PATH
whoami
getent passwd $(whoami)
echo "Let's force bash"
bash -c '
set -x
pushd /etc
popd
set +x
'
echo "...and now the same thing directly"
set -x
pushd /etc
popd
The test fails:
01:32:13,482 INFO - Running step...
01:32:13,485 INFO - /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/home/qb/bin
01:32:13,485 INFO - qb
01:32:13,486 INFO - qb:*:1008:1008:qb agent:/home/qb:/usr/local/bin/bash
01:32:13,487 INFO - Let's force bash
01:32:13,488 INFO - /etc ~/buildagent/workspace/73
01:32:13,488 WARN - + pushd /etc
01:32:13,488 WARN - + popd
01:32:13,488 INFO - ~/buildagent/workspace/73
01:32:13,488 WARN - + set +x
01:32:13,488 INFO - ...and now the same thing directly
01:32:13,488 WARN - + pushd /etc
01:32:13,488 WARN - /home/qb/buildagent/temp/command10730626365043457469.sh: pushd: not found
01:32:13,488 WARN - + popd
01:32:13,488 WARN - /home/qb/buildagent/temp/command10730626365043457469.sh: popd: not found
01:32:13,490 INFO - Executing post-execute action...
01:32:13,490 ERROR - Step 'master>test script' is failed: Failed to run command:
FreeBSD does not have runuser command which would mean the agent would use 'su' to switch to user 'qb'. Trying that on the command line results in a successful switch to user 'qb' with the shell set to bash:
root@qba7:~ # su qb
[qb@qba7 /root]$ id
uid=1008(qb) gid=1008(qb) groups=1008(qb),0(wheel)
[qb@qba7 /root]$ pushd /etc
/etc /root
[qb@qba7 /etc]$ popd
/root
[qb@qba7 /root]$ exit
So I would think the agent actually does run with bash as the shell but somehow it is ignoring it when invoking steps.
How do I make QB agent call shell scripts with bash?
Thank you so much,
Waldemar