I have a Jenkins's master-slave structure setup created having Master on windows server, plus few windows slaves and one Mac-slave. The flow is like this,
The first step where it triggers the shell script is working fine on both windows and mac slave.
#!/bin/bash
echo “This is a shell script acting as a middleware to trigger the NAnt....”
echo "Calling NAnt...."
nant ${1} ${2} ${3} ${4}
2.Now, the sample.command has a code to trigger a nant command, which is not working on mac slave and giving me an error : nant: command not found
3.The NAnt is installed on the Mac-slave through brew and when I trigger this shell script sample.command from the Mac machine, it works fine and executes the nant command, but doesn't work through jenkins.
I was able to solve this by setting up the $PATH variable at the beginning of the shell script. Just added the below line in the shell script,
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet/bin
The Paths mentioned here might be different on other machines, what I did is, I checked the $PATH while calling the shell from Mac machine and copy-pasted and that worked.