Continuous Integration for IOS with Jenkins - ios

Followed this article, http://blog.shinetech.com/2011/06/23/ci-with-jenkins-for-ios-apps-build-distribution-via-testflightapp-tutorial/ for Jenkins setup in IOS.Resulting in, Clean succeeded, xcode build succeeded, creating ipa but at the end "Build step 'Execute shell' marked build as failure" & Could not connect to SMTP host to send mail. Finished: FAILURE.
My Shell script is, xcodebuild -target EmailTests -configuration Debug -sdk iphonesimulator | ./ocunit2junit.rb
Kindly help me to clear this issue.

Related

Jenkins marked build as failure, although all test case passed for iOS app

I am using Jenkins job for running current test cases for iOS app. using,
xcodebuild test ... | xcpretty
Although all tests are successful but Jenkins still marked build as failure.
How can I see the actual result?
Edit-1:
Even when i removed | xcpretty, still jobs marked as failure. Here are the full shell command,
xcodebuild test -workspace App.xcworkspace -scheme App -destination 'platform=iOS Simulator,name=iPhone 6, OS=10.2'
Finally the problem was solved by placing below line at the very begining of jenkins shell
#!/bin/sh

Xcode 8 Build with Jenkins CI

I'm having issues with automated jenkins build on a mac pro using Xcode 8.1 with xcodebuild.
I would like my setup to:
Pull down code for git (working)
Archive (Archive fails)
Create .ipa
Deploy to TestFairy
My archive script is failing but still creating ProjectName-Daily.xcarchive file:
xcodebuild -workspace ProjectName.xcworkspace -scheme ProjectName-Daily -configuration Release clean archive -archivePath ~/ProjectName-Daily.xcarchive DEVELOPMENT_TEAM=1234567890
Fails with the following on the terminal with no description on error. I also tried -verbose and no luck
I then tried to build it manually and get a build succeeds with the following errors:
I then went to archive the build on Xcode and it worked just fine. Not sure why the script isn't working on the CI machine. Also tried the script on my personal macbook pro and it worked just fine.
Any thoughts?

jenkins integration xcode - shell command

I have integrated my xcode project with jenkin.I have got xcode build succeeded, creating ipa but at the end "Build step 'Execute shell' marked build as failure" & Could not connect to SMTP host to send mail. Finished: FAILURE.
My Shell script is, xcodebuild -target EmailTests -configuration Debug -sdk iphonesimulator | ./ocunit2junit.rb SMTP details copied from Mac Mail--> Preferences to Jenkins Configuration.
Kindly help me to clear this issue.
Seems more like Jenkins configuration issue.
Go to Manage Jenkins -> Configure System and apply the changes as show in screenshot.
Try running your command:
xcodebuild -target EmailTests -configuration Debug -sdk iphonesimulator | ./ocunit2junit.rb from a shell in Terminal. If it has the same error when you run outside Jenkins you can stop worring about Jenkins. If it dose work, try to figure out how the 2 environments differ.
Also try connecting to the smtp server manually, from the same machine that you are running the test on. First look up the smpt server using nslookup then connect with telnet to tcp port 25. Here are details for checking the mail connection: https://www.port25.com/how-to-check-an-smtp-connection-with-a-manual-telnet-session-2/

TeamCity + Xcode 6 - Run Test action fails

I am trying to make a simple Xcode project work with TeamCity. Without running any tests I have succeeded.
I have a basic, Single View Application in Swift with one label on the screen. Both TeamCity (9.0.2) and Xcode (6.1.1) runs on the same machine (Mac mini) with an OS X (10.10.2) Server (4.0.3) installed on it. I have created a Git repository with Server and added as a remote to my sample Xcode project. After that, I've created successfully a working TeamCity project and build.
However when I try to check the Run tests checkmark the build WILL fail no matter what I do.
Configuration (dropbox image)
https://dl.dropboxusercontent.com/u/55101816/Screen%20Shot%202015-03-01%20at%2002.45.48.png
Error message (and the messages right before that)
[02:31:48][FirstTeamCityProjectTests (BUILD)] Touch
[02:31:48][Touch] Touch build/Debug-iphoneos/FirstTeamCityProjectTests.xctest
[02:31:48][Touch] cd /Library/TeamCity/buildAgent/work/55b27ad210b8fe77
[02:31:48][Touch] export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/> ontents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Server.app/Contents/ServerRoot/usr/bin:/Applications/Server.app/Contents/ServerRoot/usr/sbin"
[02:31:48][Touch] /usr/bin/touch -c /Library/TeamCity/buildAgent/work/55b27ad210b8fe77/build/Debug-iphoneos/FirstTeamCityProjectTests.xctest
[02:31:48][FirstTeamCityProjectTests (BUILD)] CodeSign
[02:31:48][CodeSign] CodeSign build/Debug-iphoneos/FirstTeamCityProjectTests.xctest
[02:31:48][CodeSign] cd /Library/TeamCity/buildAgent/work/55b27ad210b8fe77
[02:31:48][CodeSign] export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
[02:31:48][CodeSign] export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/ Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Server.app/Contents/ServerRoot/usr/bin:/Applications/Server.app/Contents/ServerRoot/usr/sbin"
[02:31:48][CodeSign] Signing Identity: "iPhone Developer: *"
[02:31:48][CodeSign] /usr/bin/codesign --force --sign * /Library/TeamCity/buildAgent/work/55b27ad210b8fe77/build/Debug-iphoneos/FirstTeamCityProjectTests.xctest
[02:31:48][Step 1/1] ** BUILD SUCCEEDED **
[02:31:48][Step 1/1] xcodebuild: error: Failed to build workspace FirstTeamCityProject with scheme FirstTeamCityProject.
[02:31:48][Step 1/1] Reason: Xcode cannot run using the selected device.
[02:31:48][Step 1/1] Process exited with code 70
[02:31:48][Step 1/1] Step Xcode Project failed
Main problem I found with this error code and CI that they were trying with ssh and there were no GUI session. Currently I have a valid GUI session with the same user it uses, so it shouldn't be a problem.
The xcodebuild command is the following.
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace FirstTeamCityProject.xcodeproj/project.xcworkspace -scheme FirstTeamCityProject SYMROOT=/Library/TeamCity/buildAgent/work/55b27ad210b8fe77/build OBJROOT=/Library/TeamCity/buildAgent/work/55b27ad210b8fe77/build clean build test
What is missing here (I suppose) is one or more destinations.
I've executed the following command and it worked just fine. (Opened the Simulator, then exited with success.)
xcodebuild test -project FirstTeamCityProject.xcodeproj -scheme FirstTeamCityProject -destination 'platform=iOS Simulator,name=iPhone 6,OS=8.1'
I seem to be alone with this problem, I didn't find any other relevant hits. Looking at this tutorial: http://pivotallabs.com/ios-continuous-deployment-teamcity-hockeyapp/, my issue should not be present at all.
EDIT:
The destination is indeed missing, but I don't understand why. Moreover if I try to add it manually the build fails. (I suspect that the order of the parameters matters, but how could I add this destination elsewhere in TeamCity.)
[01:48:12][Step 1/1] Building project: /Library/TeamCity/buildAgent/work/55b27ad210b8fe77/FirstTeamCityProject.xcodeproj
[01:48:12][Step 1/1] Using Xcode 6.1.1
[01:48:12][Step 1/1] Starting: /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace FirstTeamCityProject.xcodeproj/project.xcworkspace -scheme FirstTeamCityProject SYMROOT=/Library/TeamCity/buildAgent/work/55b27ad210b8fe77/build OBJROOT=/Library/TeamCity/buildAgent/work/55b27ad210b8fe77/build clean build test -destination 'platform=iOS Simulator,name=iPhone 6,OS=8.1'
[01:48:12][Step 1/1] in directory: /Library/TeamCity/buildAgent/work/55b27ad210b8fe77
[01:48:12][Step 1/1] xcodebuild: error: option 'Destination' requires at least one parameter of the form 'key=value'
I appreciate any idea you have! Thanks in advance!
in team city, when you configure the 'Xcode Project' build step,
add the destination parameter in the 'Additional command line parameters'
input box like so:
"-destination" "platform=iOS Simulator,name=iPhone 6,OS=8.4"
pay attention to the quotation marks
that solved the issue for me (I checked it on TeamCity Professional 9.1.5 (build 37377)).
Please see How to start TeamCity Build Agent on Mac OS on a user logon to make it able to run the GUI applications (also see the note for Yosemite OS).

Jenkins-ios: how to launch the iphone simulator from Jenkins

I'm using the Jenkins CI as build management tool on the build server and I am running my unit test cases using the below command through Jenkins.
export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer/
xcodebuild -sdk iphonesimulator -project MyStore2.xcodeproj -scheme MyStore2 -configuration Debug RUN_APPLICATION_TESTS_WITH_IOS_SIM=YES ONLY_ACTIVE_ARCH=NO clean test 2>&1 | /usr/local/bin/ocunit2junit
The iPhone simulator is not launched from the Jenkins UI, whereas if I use the same command in command prompt, it is working fine.
The build console output is as below:
/Users/Shared/Jenkins/Home/workspace/iOSUnitTestCaseSample/MyStore2/Images.xcassets
2014-08-12 03:11:38.979 IBCocoaTouchImageCatalogTool[92947:303] CFPreferences: user home directory at file:///Users/Shared/Jenkins/Library/Application%20Support/iPhone%20Simulator/User/ is unavailable. User domains will be volatile.
/* com.apple.actool.compilation-results */
/Users/Shared/Jenkins/Library/Developer/Xcode/DerivedData/MyStore2-cfjvjlzuxlhdpddpszyhlozlqjdw/Build/Products/Debug-iphonesimulator/MyStore2.app/LaunchImage-700-568h#2x.png
/Users/Shared/Jenkins/Library/Developer/Xcode/DerivedData/MyStore2-cfjvjlzuxlhdpddpszyhlozlqjdw/Build/Products/Debug-iphonesimulator/MyStore2.app/Assets.car
/Users/Shared/Jenkins/Library/Developer/Xcode/DerivedData/MyStore2-cfjvjlzuxlhdpddpszyhlozlqjdw/Build/Intermediates/MyStore2.build/Debug-iphonesimulator/MyStore2.build/assetcatalog_generated_info.plist
.
.
.
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/dsymutil /Users/Shared/Jenkins/Library/Developer/Xcode/DerivedData/MyStore2-cfjvjlzuxlhdpddpszyhlozlqjdw/Build/Products/Debug-iphonesimulator/MyStore2Tests.xctest/MyStore2Tests -o /Users/Shared/Jenkins/Library/Developer/Xcode/DerivedData/MyStore2-cfjvjlzuxlhdpddpszyhlozlqjdw/Build/Products/Debug-iphonesimulator/MyStore2Tests.xctest.dSYM
Please guide me on how to resolve this issue. Help Appreciated.
Thanks.
I've solved this in the past by using the JNLP client on the Jenkins slave and having a user logged in. My theory is that if you launch the slave agent via SSH, there is no windowing environment for the simulator to run in.
Another solution is to use ios-sim.

Resources