Integrating Appium and Jenkins

4,716 views
Skip to first unread message

Anuj Yadav

unread,
May 28, 2014, 5:14:07 AM5/28/14
to appium-...@googlegroups.com
Hi,

I am trying to integrate Appium and Jenkins so that I can run my iOS test cases (using cucumber) from Jenkins. I can run these cases from command line successfully. The only problem which I am facing is in starting Appium Server. 

Jenkins do not allow me to start Appium Server, it complains that process is leaking. I even tried starting Appium using Daemonize but then the tests will TimeOut (instruments will not respond).

As a work around I am runnning Appium server from command line for now. I would like to have all this integrated in Jenkins so that no manual intervention is needed. 

Please point me in right direction, to how to integrate following steps properly:

1. Fetch code from repo (Done)
2.a. Start appium server - [appium --no-reset &] (Complains for process leak) 
2.b. Start appium server - [daemonize -E BUILD_ID=dontKillMe /usr/local/bin/appium --no-reset &] (Net:ReadTimeOut, Instruments not responding)
3. Run cucumber tests [bundle exec cucumber features/plain_note.feature] (Done)

Please help me. It is really urgent.

Regards,
Anuj

Vic Wong

unread,
May 29, 2014, 3:01:33 AM5/29/14
to appium-...@googlegroups.com

Here's how we've done it: Launch appium, Save the PID, and add a trap statement to terminate the process on interrupt/script end. You can put this in "Execute Shell" build step before your test runs. See sample shell script below

---------------

#Start appium server

appium_log=appium.log

appium_cmd="node <REPLACE_WITH_APPIUM_PATH>/appium/lib/server/main.js"

echo "[INFO] Appium command: $appium_cmd"

$appium_cmd &> $appium_log&

appium_pid=$!

#check if appium was successfully started

sleep 1

appium_pid_start=`ps -p $appium_pid | grep node | awk '{ print $1 }'`

if [ -z $appium_pid_start ] ; then

echo "[ERROR] Appium failed to start! Port $appiumport may be already in use. "

exit 1

fi

echo "[INFO] Appium started with pid: $appium_pid . Logging to: ${appium_log}"

# be sure to kill appium on script stop

trap "kill $appium_pid" SIGINT SIGTERM EXIT

Anuj Yadav

unread,
May 30, 2014, 2:30:51 AM5/30/14
to appium-...@googlegroups.com
Hi Vic,

Thanks for your reply!!!

This script starts appium and then the job remains stuck at that step. I want to run appium and then execute tests using same job. Is it possible?

Regards,
Anuj

Miriam lopes

unread,
Sep 3, 2014, 2:09:40 PM9/3/14
to appium-...@googlegroups.com
Hi!

I was using the script provided but without success.. i always got the follow error:

[EnvInject] - Loading node environment variables.
Building in workspace /Users/SWQA/Desktop
[Desktop] $ /bin/sh -xe /Users/Shared/Jenkins/tmp/hudson1354756946659329446.sh
+ appium_log=appium.log
+ appium_cmd='node /usr/local/bin/appium/lib/server/main.js'
+ echo '[INFO] Appium command: node /usr/local/bin/appium/lib/server/main.js'
[INFO] Appium command: node /usr/local/bin/appium/lib/server/main.js
+ appium_pid=361
+ sleep 1
+ node /usr/local/bin/appium/lib/server/main.js
++ ps -p 361
++ grep node
++ awk '{ print $1 }'
+ appium_pid_start=
+ '[' -z ']'
+ echo '[ERROR] Appium failed to start! Port  may be already in use. '
[ERROR] Appium failed to start! Port  may be already in use. 
+ exit 1
Build step 'Execute shell' marked build as failure
Finished: FAILURE

Apart from that, when i try to run my env.rb from jenkins shell there are errors regarding the requires that i have on the file such as: 'require rspec' and 'require selenium-webdriver'. The error tells me that "no such file to load" and as so nothing more is done. However i have these gems installed. When i run the tests (feature and env.rb) from my console everything works correctly.

How can i resolve this on jenkins?
Can you help me on this?

Thanks
Reply all
Reply to author
Forward
0 new messages