Start appium with AppiumDriverLocalService on Mac OS Jenkins node for iOS returns 65 code (when on jenkins node appium already started manually from terminal - everything ok)

Hi all.
When I start appium from code with AppiumDriverLocalService on Mac OS Jenkins node for iOS tests I see the following

remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65
xcodebuild error message:
. Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.

I don’t know the reason, because

  1. if I start appium for android programmatically - everything ok
  2. If I start appium for iOS programmatically from Intellij IDE - everything ok
  3. Also AppiumDriverLocalService starting server, I see that appium works on correct port and url

Promblem only for iOS and when I starting run on MacOS node(slave) from Jenkins using maven command.

Who has any idea how to fix?

Appium 1.22.3
Xcode 13.1

Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md

I’ve followed this tutorial. And as I mention before -
I don’t see problem if appium already started manually on jenkins node from terminal
Only when start appium from code on jenkins node

Sounds like a config problem. When you do this:

Are you logged in as same user Jenkins uses (like, ‘build’, or ‘jenkins’)? Also, can you post the full log of failure as Git Gist?

Also, what if you run the Maven command from terminal? You should try to run it manually the same exact way your Jenkins job would run or you are not comparing the same procedure.

Here logs in gist https://gist.github.com/SergiyBelevitnevSFLY/7c6ffeafc5a9ef4779a69eecfc7eb732

Also if I run the maven command from terminal - everything ok.

Jenkins user just not see environment.

Simple test. Compare output of

echo $PATH

under jenkins user (you can add this line as command in jenkins job config)

And when you execute it yourselve in terminal.

You are right - it “echo $PATH” returns nothing
But why (from your point of view) in this case, android part works without problems. I use the same configiration and starting appium with Runtime.getRuntime().exec() for android - and everything ok

not sure. all in your code.

to solve issue add in jenkins inject environment variables. and just copy correct output of echo $PATH there.

It’s either not the same user, or the shell scripts you use only set $PATH for login shells. I’m guessing you are on a recent OS (with zsh), so:

https://apple.stackexchange.com/questions/388622/zsh-zprofile-zshrc-zlogin-what-goes-where

it can be same user BUT it can cause the way how jenkins and slave connects to each other (without inheriting environment).

Yes, that’s an ‘interactive’ vs ‘non-interactive’ shell. I’m sorry if I wasn’t clear. The link has those details. I believe that when Jenkins runs a scheduled job the shell is ‘non-interactive’.

Of course there are ways to set the $PATH from within the Jenkins pipeline, but then you have to do it for each job :frowning:. Much better to set the appropriate shell scripts.

Edited to add: There is a handy way to check all environment variables on this webpage. May be really helpful:

We can inject it into slave config in jenkins in one place.

Sure, that’s fine. You should add a link to a tutorial that shows people how to do that.

it is too simple ->

1 Like

No such thing around here :slight_smile:

1 Like

Hm, I found out that environment variables in jenkins was already set. User from jenkins is the same as login user. Also as I use appiumdriverlocalservice - I’m setting “PATH” as parameter. But still no progress(

Could always follow my suggestions :wink: