Programmatically launching appium server via jenkins on Mac

I have installed appium via npm commands and after doing so it works perfectly fine if I launch the appium server manually from the terminal with just the command:- appium

Now, I wanted to get rid of this manual step, so I added the capability of launching the appium server into my scripts using the following code:-

                     DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
		String comm = "appium";
		CommandLine command = CommandLine.parse(comm);
		DefaultExecutor executor = new DefaultExecutor();

When I try to execute this piece of code on my mac in the terminal then also it works fine and starts the appium server successfully.

I am also having a jenkins server installed on this mac and when I try to execute the same piece of code mentioned above via jenkins job then it fails. It’s not able to start the appium server at all.
I am struggling to find a solution to this since last two days
Any help will be highly appreciated

Thanks in Advance,
Nishant Shah

Sounds like a $PATH error. What error do you get from Jenkins? You may need to set $PATH or another environment variable to get this working.

You need to set the Environment in jenkins