Issue with shell script and path settings on mac node

Dear community,
I have an issue / question about mac node, path settings and sh command from pipeline.
I add a path to cmake program in /etc/paths on mac node.
All users can call cmake in terminal without using the complete program path - just call cmake.

If I try to execute cmake in a pipeline like this

stage (‘Build’) {
steps {
script {
sh ‘’’

I get this error
/users/jenkins/workspace/app@tmp/durable-7916333f/ line 2: cmake: command not found

If I add an environment block to the pipeline like this

environment {
it works fine.

By adding the path to /etc/paths on mac node cmake should always run without a program path or?
Is this a permission problem on the mac node?

Thanks in advanced and best regards

Are you using ssh to connect to the node? If so, environment files are not sourced in that case, so that paths file will not be used. Adding it to the environment in the pipeline is probably the way to go to make sure you are using the correct cmake.

I recommend adding it to your node on the /computers/ page, that way you don’t have to update it in every pipeline.

Or making a shared library for calling cmake that updates the PATH just for that one call.

But as you have, and as slide says, what you have works really well

1 Like

Thanks very much for the very fast answer.
And yes I use ssh.
One more question - I did this exactly the same way on a windows node.
Add paths to the system environment variables and here it runs perfectly.
So Windows and Mac will work differenty with path settings?

Yes, the path behaves differently on Windows and Unix. If you set the path in the system properties on Windows, it will apply to all users regardless if environment files are sourced or not, this is specific to Windows because Windows uses the registry for things like this. On Unix varieties, if the file is not sourced somehow, then it won’t take affect for that session.

Thanks for your explanation now it is understandable
Best regards