jenkins integration xcode - shell command - ios

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/

Related

Self Hosted Agent on macOS not working with Azure Pipeline

This is an issue I've been facing for the past week.
I have an M1 Mac Mini setup as a self-hosted agent to run iOS related builds/archives through Azure Pipelines.
I'm able to build/archive locally on the machine itself using terminal. Mobile provisioning and code signing are setup and working fine.
When I run the agent interactively using run.sh, I am able to run the pipeline successfully. When I try running the agent as a launchd service using ./svc.sh install -> ./svc.sh start, it always fails with the same error:
** ARCHIVE FAILED **
The following build commands failed:
ValidateEmbeddedBinary /Users/<user>/Library/Developer/Xcode/DerivedData/<project>/Build/Intermediates.noindex/ArchiveIntermediates/<app-name>/BuildProductsPath/Debug-iphoneos/<app-name>.app (in target '<app-name>' from project '<project>')
(1 failure)
##[error]Bash exited with code '65'.
The command I'm using to archive is
xcodebuild -workspace ~/repos/<project>/<project>.xcworkspace -scheme <app-name> -allowProvisioningUpdates clean archive -archivePath build/<app-name> -destination generic/platform=iOS
Again, this command works when I run it locally and when I run the agent interactively.
I removed app/project names for privacy reasons.
I've searched high and low as to why this error is occurring and I've tried virtually all suggestions to fix it. For the life of me I don't know why the command would work locally and when the agent is run interactively, but does not work when the agent is run as a launchd service.
Edit: I’ve noticed a pattern: the archive fails with that error after every successful run. In other words the command successfully archives but when I run it again, it fails. If I run it once more, it’s successful. This occurs when running it through Azure Pipelines and locally via terminal. I have no words!

Continuous Integration for IOS with Jenkins

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.

Jenkins - xcodebuild connection peer refused refused channel request for dtxproxy:XCTestManager_IDEInterface

I'm attempting to run an xcodebuild command using Jenkins to build my code periodically. The error message that Jenkins is spitting out is:
14:18:25.993 xcodebuild[24225:349241] Connection peer refused channel
request for
"dtxproxy:XCTestManager_IDEInterface:XCTestManager_DaemonConnectionInterface";
channel canceled
14:18:25 Testing
failed:
14:18:25 Test target PROJECT_NAME encountered an error
(Invalid device state If you believe this error represents a bug,
please attach the log file at
/var/folders/hp/3m4jx3514dq4lf1l9s8hk5qh00009c/T/com.apple.dt.XCTest-status/Session-2015-08-05_14:18:22-ulOdQQ.log)
14:18:25 ** TEST FAILED **
My question is what is this error and how can I fix it? When xcode build command is run in the command line, I receive the same error. I'm using Xcode 6 and the command I'm running is:
xcodebuild -workspace PROJECT_NAME.xcworkspace -scheme 'Scheme Name'
-destination 'platform=iOS Simulator,name=iPad Air,OS=8.1' clean build test
While Fiddling around with the items below, I finally have a few successful builds. I still don't know the root cause. The internet doesn't seem to either.
Add "clean build" to the command line options (as specified above)
Kill the simulator Prior to the command - sort of suggested here: (Instruments error: Connection peer refused channel request)
killall "Simulator" || echo "No matching processes belonging to you were found"

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