Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Provisioning iOS CI Server with Ansible

283 views

Published on

Talk about provisioning iOS CI mac mini servers using Ansible.
These are the slides for my presentation for Ansible London Meetup. https://www.meetup.com/Ansible-London/events/241643732/

Published in: Software
  • Be the first to comment

  • Be the first to like this

Provisioning iOS CI Server with Ansible

  1. 1. Building iOS CI Servers with Ansible London Ansible Meetup Shashikant Jagtap Twitter: Shashikant86 Github: Shashikant86 Blog: http://shashikantjagtap.net/
  2. 2. Topics ✤ Overview of iOS CI ✤ Software Required for Setting iOS CI ✤ Challenges using Ansible for macOS ✤ Ansible Tasks, Playbooks and Roles
  3. 3. Continuous Integration: iOS
  4. 4. Static Analysis : SwiftLint
  5. 5. Build : xcodebuild
  6. 6. Test : XCTest
  7. 7. Archive : ipa
  8. 8. Upload : iTunes Connect
  9. 9. iOS Self hosted CI
  10. 10. iOS Cloud CI
  11. 11. Setting up iOS CI Server
  12. 12. Xcode Command LineTools
  13. 13. Build Automation: Fastlane ✤ https://fastlane.tools/
  14. 14. Package Managers for iOS ✤ CocoaPods, Carthage, Swift Package Manager
  15. 15. Package Managers for macOS ✤ Homebrew
  16. 16. Apple Certificates & Profiles ✤ Development & Distribution Certificates ✤ Provisioning Profiles
  17. 17. Manually Setting up CI Server
  18. 18. Why Provisioning ? ✤ Avoid repeating manual work ✤ Say No to “Works on My Machine” ✤ Infrastructure As Code ✤ Ability to reset and reconfigure CI infrastructure
  19. 19. What Are Choices ?
  20. 20. Hello Ansible
  21. 21. Challenges ✤ It’s not Linux ✤ Proprietary Softwares from Apple ✤ Not much Ansible roles for macOS ✤ Not much Ansible modules supporting macOS packages ✤ Testing the macOS roles
  22. 22. Ansible Automates Everything
  23. 23. Provisioning Xcode Installation --- - name: Mount Xcode XIP from hosted Server command: bash -c "mount_smbfs //{{ ansible_env.SAMBA_USER}}:{{ ansible_env.SAMBA_PASS }}@our_server/Applications/xcode/ ~/samba/public/" when: xcode_dir.stat.exists == False - name: Install Xcode from XIP file Location command: bash -c 'open -FWga "Archive Utility" --args ~/xcode_xip/{{ xcode_src }}' - name: Move Xcode To Application command: bash -c 'mv ~/xcode_xip/Xcode*.app /Applications/' - name: accept license agreement command: /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -license accept become: yes become_method: sudo - name: install additional xcode components command: installer -pkg /Applications/Xcode.app/Contents/Resources/Packages/ XcodeSystemResources.pkg -target / become: yes
  24. 24. Provisioning Homebrew Packages --- - name: Ensure configured taps are tapped. homebrew_tap: "tap={{ item }} state=present" with_items: "{{ homebrew_taps }}" - name: Ensure configured homebrew packages are installed. homebrew: "name={{ item }} state=present" with_items: "{{ homebrew_installed_packages }}" - name: Install configured cask applications. homebrew_cask: name: "{{ item }}" state: present install_options: "appdir=/Applications" with_items: "{{ homebrew_cask_apps }}" when: configure_cask
  25. 25. Ruby + RVM for RubyGems --- - name: Install RVM for the user command: bash -c "curl -sSL https://get.rvm.io | bash -s -- --ignore-dotfiles" - name: Install ruby version command: bash -c "~/.rvm/bin/rvm install {{ ruby_version }} --with-zlib-dir={{ zlib_directory }}" - name: Install Ruby Gems required for iOS app developement command: bash -c "~/.rvm/rubies/{{ ruby_version }}/ bin/gem install {{item}}" with_items: "{{ rubygems_packages_to_install }}"
  26. 26. Provisioning macOS Defaults --- - name: Setup macOS Sleep Mode shell: "{{ item }}" with_items: "{{ macos_sleep_options }}" changed_when: false - name: Software Updates shell: "{{ item }}" with_items: "{{ macos_software_autoupdates }}" changed_when: false
  27. 27. CI Server Specific Examples: TeamCity --- - name: "Download Teamcity Agent Package" command: bash -c "curl {{ teamcity_agent_server_url }}/update/ buildAgent.zip --output /tmp/buildAgent.zip" register: _teamcity_agent_package - name: "Add TeamCity Agent configuration" template: src: "buildAgent.properties.j2" dest: "{{ teamcity_agent_install_dir }}/conf/ buildAgent.properties" mode: 0644 - name: Start the Teamcity Agent command: bash -c "{{ teamcity_agent_install_dir }}/bin/ agent.sh start"
  28. 28. Example Playbook - hosts: localhost connection: local xcode_src: Xcode_8.3.xip ruby_version: ruby-2.3.0 zlib_directory: /usr/local/Cellar/zlib/1.2.11 rubygems_packages_to_install: - bundler teamcity_agent_install_dir: ~/TeamCity/buildAgent teamcity_agent_server_url: https://our_teamcity_server.com teamcity_agent_name: Our_iOS_Agent macos_sleep_options: - systemsetup -setsleep Never - systemsetup -setharddisksleep Never - systemsetup -setcomputersleep Never macos_software_autoupdates: - softwareupdate --schedule off homebrew_installed_packages: - autoconf - openssl - wget homebrew_taps: - homebrew/core - caskroom/cask tasks: - include: tasks/ios_ansible.yml
  29. 29. Ansible Role on Galaxy :iOS-Dev ✤ https://galaxy.ansible.com/Shashikant86/iOS-Dev/
  30. 30. Source Code on GitHub: ansible- ios-ci ✤ https://github.com/Shashikant86/iOS-Dev-Ansible
  31. 31. Testing macOS Playbooks ✤ Vagrant Box ✤ Cloud based CI servers e.g TravisCI
  32. 32. Testing onTravis CI
  33. 33. Benefits ✤ Infrastructure as Code ✤ Quick Setup of new CI Server Machine ✤ Ability to Switch between Xcode Version ✤ Ability to reset and rebuild CI Sever Machines ✤ Streamline configuration of local machine and CI server
  34. 34. Blog Posts ✤ iOS CD with Fastlane and Ansible : Part 1 ✤ http://shashikantjagtap.net/ios-continuous- deployment-fastlane-ansible-part-1/ ✤ iOS CD with Fastlane and Ansible: Part 2 ✤ http://shashikantjagtap.net/ios-continuous-delivery- fastlane-ansible-part-2/
  35. 35. Questions?

×