Hands on iOS developments with jenkins
-
Upload
arnaud-heritier -
Category
Technology
-
view
4.848 -
download
2
description
Transcript of Hands on iOS developments with jenkins
![Page 1: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/1.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Hands-On iOS Developments with Jenkins
Arnaud Héritier eXo Platform
http://www.exoplatform.com
Mathieu Hausherr Octo Technology
http://www.octo.com
http://goo.gl/XWGDy 1
![Page 2: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/2.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Polls
• English or french ? • Who is already doing iOS developments ? • Who is already using JenkinsCI ? • Who is already using JenkinsCI to manage
iOS developments ?
http://goo.gl/XWGDy 2
![Page 3: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/3.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Arnaud Héritier " Jenkins
– Committer since 2010 – Maven integration – Xcode, Appaloosa plugins …
" Apache Maven – Committer since 2004 and
member of the Project Management Committee
– Coauthor of « Apache Maven » • published by Pearson (in
French)
" eXo platform – Software Factory
Manager – In charge of tools
and methods " Contact me
– http://aheritier.net – Twitter : @aheritier – Skype : aheritier
3 http://goo.gl/XWGDy
![Page 4: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/4.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Mathieu Hausherr " iOS
– Developer since 2008
" Other mobile platforms – Android, Bada, Blackberry,
Windows Phone 7...
" Octo Technology – Mobile Expert – Installation of software
factories for customers
" Contact me – Mail: [email protected] – Twitter : @mhausherr
4 http://goo.gl/XWGDy
![Page 5: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/5.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Slide legend
http://goo.gl/XWGDy 5
" If you have a mac with XCode, follow us.
" In this slide you have something to do.
" In this slide we explain a workaround. Don’t be afraid by this explanation. You only need it tomorrow at home for your own Software factory.
" Find these slides here
![Page 6: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/6.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Hands-On iOS Developments with Jenkins
" Concepts – iOS specificities – Continuous integration – Continuous deployment
" How to – Step by step Jenkins server setup – Tips & Tricks to deals with Apple’s bug
" Hands on – Prepare the Sample App – Setup your Jenkins jobs – Deploy your app on your device
6 http://goo.gl/XWGDy
![Page 7: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/7.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
CONCEPTS Goals of Jenkins-CI on iOS
7 http://goo.gl/XWGDy
![Page 8: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/8.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Reminder: Apple application provisioning strategy
Validity Limite of devices
Apple validation Availability
Ad Hoc 1 year 100 NO Everybody
In House 1 year ∞ NO Only for
companies
App Store For life ∞ YES Everybody
8 http://goo.gl/XWGDy
![Page 9: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/9.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Certificate management pitfalls
• Certificate with the same name doesn’t work
• Create specific keychains per project – Never use default keychain
• “security set-default” command isn’t thread safe – Allow only one executor per server
9 http://goo.gl/XWGDy
![Page 10: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/10.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Why automatic distribution is useful for?
• Speedup the feedback loop with early adopters and QA Teams
• Improve time to market – Spend time to develop instead of distribute
• Resign apps for certificates expiration – Ad Hoc and In House certificates expire after one
year – Rebuild all your app safely
10 http://goo.gl/XWGDy
![Page 11: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/11.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Continuous integration concepts
Developer
Developer
Source code + tests
Unit tests
SenTesting
Source code + tests 1
1
2
3
Software Factory
Building application
Jenkins
Code versionning
Git
Static analysis
Clang
11 http://goo.gl/XWGDy
![Page 12: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/12.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Continuous deployment concepts
Publish
Building application
Jenkins
Private store
Appaloosa
Download
Documentation generation
Apple doc
1
2
4
Code versionning
Git
Push
5
6
User devices
Software Factory
Archive
4 Archive
Public store
App Store Submit
5
6 Download
12 http://goo.gl/XWGDy
![Page 13: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/13.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Appaloosa concept
13 http://goo.gl/XWGDy
![Page 14: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/14.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Getting your device UDID We need your device UDID to be able to push apps to your device 1. Download “UDID sender” on
the App Store 2. Send UDID via E-Mail to
http://goo.gl/XWGDy 14
![Page 15: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/15.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
HOW TO Step by step guide for Jenkins-CI on iOS
15 http://goo.gl/XWGDy
![Page 16: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/16.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Plugins installation Ø Home Ø Manage Jenkins Ø Manage Plugins
Ø Install these plugins • Appaloosa • Clang Scan-Build • Git
• Xcode
16 http://goo.gl/XWGDy
![Page 17: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/17.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Plugins configuration • By default Xcode plugin
settings should be good for a standard installation
• Clang Static Analyzer binaries have to be downloaded from http://clang-analyzer.llvm.org/ and extracted on the server or agent where they’ll be used
• In “System settings” (Clang Scan-Build Plugin part) you need to add at least one installation.
17 http://goo.gl/XWGDy
![Page 18: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/18.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
What if I soon have a Jenkins on a non Mac server? • Why use a non Mac
Jenkins? – Regroup all your jobs – Maintain only one
instance of Jenkins – Create dependencies
between mobile and not mobile projects
• How use a non Mac Jenkins? – Create Mac OS node – Only need a SSH
connection
http://goo.gl/XWGDy 18
Master Node
Scheduling build
Jenkins
Code versionning
Git
MacOS Node
Building application
XCode
![Page 19: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/19.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Node creation • To create an agent
dedicated for xcode builds you need to create a node with : • A label to select jobs for
which you’ll use it • A SSH connection with a
password less private key • The path for Clang checker
binaries
19 http://goo.gl/XWGDy
![Page 20: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/20.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Affect job to a node • Create a “MacOSX” label • Force job to run on
“MacOSX”-labeled nodes
20 http://goo.gl/XWGDy
![Page 21: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/21.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Xcode bug for iOS unit testing Source: http://www.raingrove.com/2012/03/28/running-ocunit-and-specta-tests-from-command-line.html
• Edit your RunPlatformUnitTests
sudo vim `xcode-select -print-path`/Platforms/iPhoneSimulator.platform/Developer/Tools/RunPlatformUnitTests Replace Warning ${LINENO} "Skipping tests; the iPhoneSimulator platform does not currently support application-hosted tests (TEST_HOST set)."
By: export CFFIXED_USER_HOME="${BUILT_PRODUCTS_DIR}/UserHome/" mkdir -p "${CFFIXED_USER_HOME}" mkdir -p "${CFFIXED_USER_HOME}/Library/Caches" mkdir "${CFFIXED_USER_HOME}/Library/Preferences" mkdir "${CFFIXED_USER_HOME}/Documents" export OTHER_TEST_FLAGS="${OTHER_TEST_FLAGS} -RegisterForSystemEvents" RunTestsForApplication "${TEST_HOST}" "${TEST_BUNDLE_PATH}"
21 http://goo.gl/XWGDy
![Page 22: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/22.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Configure your project for Unit Tests • Check run action for your
Test target
• Share your Scheme
22 http://goo.gl/XWGDy
![Page 23: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/23.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Add Xcode unit testing build phase • Commit your scheme on GIT
• Use Scheme instead of target for testing. Use target only for building.
• Set SDK to iphonesimulator
• Set Configuration to Debug
• Add TEST_AFTER_BUILD=YES in Custom xcodebuild arguments
23 http://goo.gl/XWGDy
![Page 24: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/24.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Write a test
- (void)test_parseRoomsFromDictionary_ !returnObjectsArrayForCorrectDictionnary!{ ! // Given! NSDictionary *dictionnary = [NSDictionary dictionaryWithObject:[NSArray array] forKey:KEY_ROOMS]; ! ! // When! NSArray* rooms = [JUCEventsService parseRoomsFromDictionary:dictionnary]; ! ! // Then! STAssertTrue([rooms isKindOfClass:[NSArray class]],nil); !}
• Use SenTestKit Framework
• Add Mock With OCMock
24 http://goo.gl/XWGDy
![Page 25: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/25.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Add clang static analysis build phase • Configure your target
25 http://goo.gl/XWGDy
![Page 26: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/26.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Appaloosa jenkins’ integration • Check IPA generation
• Add Appaloosa step to your project
• Receive Push Notification
Token: igjrz4w701ynrkzd2zwh2u450ilg00dg
26 http://goo.gl/XWGDy
![Page 27: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/27.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Publish to the App Store
• Apple doesn’t provide API
• Need manual actions – On a Mac – Without proxy
27 http://goo.gl/XWGDy
![Page 28: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/28.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Generate Apple Doc • Install Apple Doc https://github.com/tomaz/appledoc
• Command line
appledoc conf.plist <outfile>
• Add an “aggregate” target to the project
Perform automatic doc generation locally
28 http://goo.gl/XWGDy
![Page 29: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/29.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
HANDS ON … LET’S GO Jenkins set-up, from GitHub to your device
29 http://goo.gl/XWGDy
![Page 30: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/30.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Fork on github the sample project
http://goo.gl/alKgW And then clone your fork git clone git://github.com/XXXX/JenkinsSample.git
30 http://goo.gl/XWGDy
![Page 31: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/31.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Setup a continuous integration job Setup Git
http://goo.gl/XWGDy 31
![Page 32: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/32.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Setup a continuous integration job Add a Clang Scan-Build Phase
http://goo.gl/XWGDy 32
![Page 33: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/33.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Setup a continuous integration job Add an Xcode build step to execute tests • Use a schema (JUC Paris) • SDK = iphonesimulator • Config = Debug
• Args = TEST_AFTER_BUILD=YES • Clean test reports
http://goo.gl/XWGDy 33
![Page 34: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/34.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Setup a continuous integration job Activate Clang and unit tests reports
http://goo.gl/XWGDy 34
![Page 35: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/35.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Fix the test In JUC ParisTests/JUC_ParisTests.m Comment the failling test Commit and push on github git add . git commit git push Relaunch your build
http://goo.gl/XWGDy 35
![Page 36: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/36.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Change your Bundle Id In Project Properties > JUC Paris Target > Summary Change Bundle identifier to com.jenkins.juc-paris.app.yourname Commit and push on github git add .
git commit git push
http://goo.gl/XWGDy 36
![Page 37: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/37.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Add a deployment Job Same github settings Create an Xcode build step • Target = JUC Paris
• Config = Release • Setup versions • Build IPA • Embedded profile
http://goo.gl/XWGDy 37
![Page 38: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/38.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Appaloosa installation on your device
http://goo.gl/hQ2Ue
http://goo.gl/XWGDy 38
![Page 39: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/39.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Appaloosa installation on your device Account information • Login:
[email protected] • Password:
jenkins
http://goo.gl/XWGDy 39
![Page 40: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/40.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Add a deployment Job Setup Appaloosa with this token : igjrz4w701ynrkzd2zwh2u450ilg00dg
http://goo.gl/XWGDy 40
![Page 41: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/41.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Enjoy
41 http://goo.gl/XWGDy
![Page 42: Hands on iOS developments with jenkins](https://reader034.fdocuments.us/reader034/viewer/2022051015/554f84beb4c905d25b8b4bee/html5/thumbnails/42.jpg)
Jenkins User Conference Paris, 17 April 2012 #jenkinsconf
Thank You To Our Sponsors
Platinum Sponsor
Silver Sponsor
Gold Sponsor
42 http://goo.gl/XWGDy