[Shared Library] Unable to run a batch commmand from a shared library

Hi

I’m in the process of moving common code from my jenkinsfile into a shared library.
Everything went well until I tried to move code that uses ‘bat’ steps.
I understand you are not supposed to call Jenkins steps from shared libraries (doable if you insist well), so I tried using the ProcessBuilder class to run cmd.
But whatever I do, I always end up with a ‘No such file or directory’. Such as ‘Cannot run program “C:\Windows\System32\cmd.exe”: error=2, No such file or directory’ (and yes, the function is called in a windows agent)

Am I doing the right thing here ?
Is Jenkins preventing me from accessing programs on the node on purpose ?

Thanks

Process builder, being a native java class doesn’t know anything about controller to agent
Would recommend you use the pipeline bat step

1 Like

Thanks for the answer

Jenkins steps are not available by default.
Does it mean I need to add the script object to my function signature so I can call script.steps. functions ?