Launch simulator and run app from command line?

1,882 views
Skip to first unread message

Ru Cindrea

unread,
Jan 20, 2013, 3:15:31 AM1/20/13
to calaba...@googlegroups.com
Hi, 

I am trying to use calabash for iOS with Jenkins and I am having trouble launching the simulator from inside a job. I've tried the following:
- manually from the command line - everything is OK
- from inside jekinks, I've tried with NO_LAUNCH = 1, everything is OK
- from inside jenkins, I've tried with a long time out and with a different simulator version => I get the 
Ping http://localhost:37265/...
Ping http://localhost:37265/...
Ping http://localhost:37265/...
Ping http://localhost:37265/...
Ping http://localhost:37265/...
Ping http://localhost:37265/...
Ping http://localhost:37265/...
Ping http://localhost:37265/...
Ping http://localhost:37265/...
Ping http://localhost:37265/...
Timed out..."

I would like to just use the NO_LAUNCH=1 option from Jenkins (I noticed that a lot of other people have had problems launching the simulator from jenkins) but I don't know how to start my application inside the simulator from the command line, is there such an option?

Thanks, 
Ru

Trevor Harmon

unread,
Jan 20, 2013, 9:44:41 AM1/20/13
to calaba...@googlegroups.com
Why do you need to set NO_LAUNCH=1 for Jenkins? If Calabash can't launch the simulator with NO_LAUNCH=0, then I think there is something wrong with your setup. I've been using Calabash with Jenkins for over a month with NO_LAUNCH=0.

Trevor

Ru Cindrea

unread,
Jan 20, 2013, 12:41:32 PM1/20/13
to calaba...@googlegroups.com
Apparently, my Jenkins environment cannot launch the simulator properly. 

If I just use "cucumber" in Jenkins (NO_LAUNCH=0), the simulator doesn't start. I've tried with a really long timeout, it still doesn't start. 

I've also tried to simply launch the simulator by using the following command:

'/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app/Contents/MacOS/iPhone Simulator' -SimulateApplication /pathtomyapp/MyApp.app

and the simulator still doesn't start - so this has nothing to do with calabash anymore... 

I have managed to solve my problem by adding the command about into a start_simulator.sh script, then I launch it from Jenkins and start the tests with "NO_LAUNCH=1 cucumber". 

I have no idea what is different about my environment. I have tried all the suggestions I could find online about setting up Jenkins, but still no luck. However, my workaround is fine for now, so maybe it will be useful for someone else as well...

Ru

Trevor Harmon

unread,
Jan 20, 2013, 3:15:53 PM1/20/13
to calaba...@googlegroups.com
I assume you're using the Jenkins Xcode plugin to build the project in Jenkins. First just try running a Jenkins job that only builds your project; don't have it run cucumber yet. Then go to the Terminal and locate the build directory. (Note that by default this is different than where Xcode puts it. I think you will find it in a "build" subdirectory of your source code, not in ~/Library/Developer/whatever.) Run cucumber from that directory and see what happens. If you still get timeouts, then you are probably building the wrong configuration or target. Make sure you're building the configuration/target that includes the Calabash framework. You will probably need to specify "MyProject-cal" (or whatever) as the target in the Jenkins Xcode plugin.

Trevor

Ru Cindrea

unread,
Mar 3, 2013, 9:18:31 AM3/3/13
to calaba...@googlegroups.com
My problem was in how Jenkins was started. I used to launch Jenkins with "sudo launchctl load /Library/LaunchDaemons/org.jenkins-ci.plist", and I couldn't start the simulator at all with that unless I used a script like I described above. 

I have now switched to launching Jenkins with "nohup java -jar /Applications/Jenkins/jenkins.war --httpPort=8080" -> this starts Jenkins under .jenkins in my home directory and I can now simply use "cucumber" to start the simulator and run the tests. 


Maybe this will help someone else as well :)

Ru

Wolas Tomasz

unread,
Mar 4, 2013, 3:33:08 PM3/4/13
to calaba...@googlegroups.com
For future issues, i had a lot of problems with running simulator on jenkins.

The problem was that jenkins installer on Mac create Jenkins user, and by default add launching script to LaunchDaemons directory.
In that way jenkins was run by daemon and all processes run by jenkins were running in background, because daemons don't have permission/ability to use window manager to paint windows.

FIX: change destination of launching script to LaunchAgents. Everything works there fine, and simulator starts.

Tomek

Mustafizur Rahaman

unread,
May 18, 2013, 5:17:23 AM5/18/13
to calaba...@googlegroups.com
Hi Tom,

Thanks for your answer. I am facing the same issue & have couple of question on the same
- How do you start jenkins if you put jenkins in /Library/LaunchAgents. If it is in LaunchDaemons, i see jenkins automatically starting when my system boots up. But if i put in LaunchAgents, it does not boot up?

- What is the difference if I launch jenkins by #1>sudo launchctl load /Library/LaunchDaemons/org.
jenkins-ci.plist & #2> nohup java -jar /Applications/Jenkins/jenkins.
war --httpPort=8080


I see #1 create a jenkins user in /Users/Shared/Jenkins where as #2 create jenkins inside ~/.jenkins

- If i keep jenkins plist in /Library/LaunchAgents & If i start jenkins by nohup java -jar /Applications/Jenkins/jenkins.
war --httpPort=8080, I see jenkins running, but then how do i stop jenkins? if I kill -9<pid> i see another jenkins.war is started as another process id. While trying to unload,I get following error

sudo launchctl unload /Library/LaunchAgents/org.jenkins-ci.plist
launchctl: Error unloading: org.jenkins-ci

Thanks,
Rahaman

Maksym Grebenets

unread,
May 22, 2013, 2:27:52 AM5/22/13
to calaba...@googlegroups.com
Hi

I heard that Jenkins fails to run simulator is launched as daemon, so I didn't even try to run it as daemon and went ahead to using launchctl.
It's pretty straightforward, you just need to pus a proper XML file in ~/Library/LaunchAgents and it will start along with OS, ans using launchctl load you can start it manually.
There are some caveats like setting a proper garbage collector or jenkins fails now and then otherwise.
Here's the org.jenkins.plist that worked for me (check the port number before using)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>KeepAlive</key>
    <true/>
    <key>Label</key>
    <string>org.jenkins-ci</string>
    <key>ProgramArguments</key>
    <array>
      <string>/usr/bin/java</string>
      <string>-server</string>
      <string>-d64</string>
      <string>-Xms512m</string>
      <string>-Xmx512m</string>
      <!-- Use Concurrent GC-->
      <string>-XX:+UseConcMarkSweepGC</string>
      <string>-XX:+CMSClassUnloadingEnabled</string>
      <!-- <string>-XX:+CMSPermGenSweepingEnabled</string> -->
      <string>-XX:MaxPermSize=256m</string>
      <!-- <string>-XX:MaxGCPauseMillis=500</string> -->
      <string>-jar</string>
      <string>/usr/local/opt/jenkins/libexec/jenkins.war</string>
      <string>--httpPort=8090</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
  </dict>
</plist>

I have a dedicated CI server that has only one user and runs Jenkins under the same account, so can't tell you what are the tricks with multiple user accounts.
And I installed jenkins using homebrew if it matters.

Krukow

unread,
May 23, 2013, 4:57:15 PM5/23/13
to calaba...@googlegroups.com
Thanks for the update.
Reply all
Reply to author
Forward
0 new messages