Jenkins pipeline pwsh on mac can't find pwsh

Hi

I’m trying to use the pwsh command on a mac, and I must be missing something because out of the box, pwsh cannot be found.
On the Mac, pwsh was installed using brew, and everything is working fine in an interactive session.
But when run through a Jenkins job (SSH agent), the PATH is very minimalist, and pwsh can’t be found.
I tried to override the PATH variable, in the Jenkinsfile and in the agent properties, but it seems to be ignored when running the pwsh step.
The only way I was able to make it work was to wrap the pwsh inside a sh step, which doesn’t look nice.

What is the proper and official way to run pwsh on a Mac ?
Tested on latest LTS 2.528.1

Thanks

The path for your jenkins agent on any OS is controlled by the Node configuration. You could either add pwsh as a tool or update the Path Environment variable in your agent’s config.