Jenkins+Appium+iOS: xcodebuild failed with code 65 (on local works only on jenkins not)

Appium 1.7.0
Node 8.5.0
npm 5.3.0
iOS real device - iPhone 7 with iOS 11, xcode 9

Description:
I have a local project (where i start appium from code); when i run it locally with intelij works perfectly. If i run it from jenkins (using exactly the same code), setup crashes when is trying to install WebDriverAgent app. It install my ipa but not the WDA. What i’m missing?

[XCUITest] Error: Unable to launch WebDriverAgent because of xcodebuild failure: “xcodebuild failed with code 65”. 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.

Log: https://gist.github.com/vjmaiky/02bc08df4c00cfaa70f641d023849824

I added:
caps.setCapability(“keychainPath”, “/Users/admin/Library/Keychains/login.keychain-db”);
caps.setCapability(“keychainPassword”, “password”);

Now i get:

[XCUITest] Error: Unable to launch WebDriverAgent because of xcodebuild failure: “Command” security -in unlock-keychain -p password /Users/admin/Library/Keychains/login.keychain-db ‘exited with code 195’. 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.
at XCUITestDriver.quitAndUninstall $ (/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/lib/driver.js:386:13)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at generatorFunctionPrototype.prototype. (anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js💯21)
at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at
at process._tickCallback (internal / process / next_tick.js: 188: 7)

any thoughts?

@maiky did you make same steps to build WDA where jenkins machine executing your code? -> https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md ?

i managed to resolve it; it was related to mac accounts; even if i had the certificates installed on admin they where not available for jenkins agent; still i gave jenkins agent the path to keychains but still it wasn’t able to use them; the solution was to install profiles also on jenkins agent and after that it worked perfectly. Thanks anyway.

hi @maiky I am still getting this error. when you say t was related to mac accounts, can you explain in bit details
it would be great help

Hi @venkat4, when i received my mac it had only 1 user on it (admin); normally when you configure Jenkins, system automatically creates a new user called Jenkins (jenkins agent which runs the jobs); my problem was that all setup was configured for admin user, and jobs are running from jenkins agent; mu fix was to make the same setup (configuring wda + profiles) also on jenkins agen; if you do not want to do that, from the start use only you jenkins user as default user (and install all your necessary data; use it as your default profile/user).

how did you resolve? can you give the steps please