jenkins+cocoapods+pgy+ Multi-version Continuous Integration

Source: Internet
Author: User
Tags ukey

Continuous integration?

Continuous integration is a software development practice in which team development members often integrate their work, with each member being integrated at least once a day, which means that multiple integrations may occur on a daily basis. Each integration is validated through automated builds, including compilation, release, and automated testing, to identify integration errors early.

Let's see what I need.
    • Continuous integration,
    • Use Cocoapod to manage third-party controls,
    • Distributed using PGY,
    • Management of three versions (Beta, Dev, appstore), and each version to be as high as possible automated continuous integration
Let's look at the idea.
    • Continuous integration with Jenkins
    • Multiple versions are managed using multiple scheme, and multi-version automation is continuously integrated by configuring Jenkins to compile different scheme
    • Of course, the premise of continuous integration is that unit testing is as comprehensive as possible
With the idea of a step-by-step to do it. 1. Prepare the Xcode project scheme configuration for each version separation
  1. Add two scheme
    We need to have two Scheme in the project. These two Scheme behaviors are the same at Debug time, but in Archive, an internal test is released for the Staging version and one for the App Store.

    The Settings entry for scheme is on the menu: "Product", "scheme", "Manage schemes".
  2. Add a new compilation configuration Forbeta
  3. Setting the compilation configuration for scheme
    In the Scheme settings for the App Store, the Build Configuration for Run and Test uses Debug, profile, and Archive for Release.
    In the Scheme settings corresponding to Staging (Beta), run and Test also use Forbeta with Debug, profile and Archive.
  4. Different versions use different icon
    Then there is Icon. Now everyone should use Xcode 5! Since it is used, it is more used with the new features, Icon set this block I used Media Assets. If your old project has not yet been activated, then you will be bothered to enable it under General for Target.
    In Media Assets (the default name in the project should be Images.xcassets), click on the Menu "Editor", "new app icon" to create two new app icons, corresponding to Debug and Staging Version. Then drag the previously prepared icons into each. :

    After you set up Media Assets, you also have to set different versions in the corresponding Target build Settings to use different App icons. :

    With this set up, different versions of the app will have their own different icons.
  5. Bundle ID
    Again, it is set according to the Bundle ID we defined earlier and the corresponding relationship of each version.
    We need to define a variable in Build Settings. Entry in: "Editor", "Add Build Setting", "Add user-defined Setting".

    Then set the Bundle ID to the variable we just defined in the corresponding Target's Info.

    In this way, the project can use different Bundle IDs when compiling with different configuration files.
  6. AppName
    Set the icon, if you feel the need to apply the name of the way to distinguish, it is also possible.
    We need to define a variable in the Build Settings. For example, I define this:

    Then use this variable in the settings of the app name:

So far, we can choose different scheme to compile the different versions, the following for continuous integration

2. Install Jenkins

Because Jenkins's PKG installation package default installation location is shared folder, need permission to modify, pod install cannot execute sudo command, so give up pkg installation.

  1. The HOME path is automatically found before installation due to running Jenkins, and the Jenkins_home is set in advance.
    When you /etc/profile add a row
    export JENKINS_HOME="/Users/yourname/jenkins"

  2. Directly download the war package to your personal directory /Users/yourname/jenkins
    Using named
    java -jar jenkins.war --httpPort=8008 &
    Install and run

  3. Open localhost:8008 go to jenkins-> System Management--admin plug-in installs two plugins cocoapod and Xcode, one for managing dependent libraries, one for Xcode compilation option settings


  4. Here's an option for Xcode schemes file, you can choose to fill in the project benefit configuration xxxx-Beta so that you can package different versions of IPA.
    The. IPA filename Pattern IPA file name, written to the same name as the Jenkins Project, is easy to distinguish, and the following Python script will also use to locate the file
    Target->configuration can be configured to write Forbeta, Debug, Release

  5. Add build steps Execute Shell for unit testing
    Install the Ocunit2junit plugin, generate a test report that is visible to Jenkins, and add the shell
    if [-d "test-reports"]
    then
    rm -rf test-reports
    fi
    xcodebuild test -workspace yourProject.xcworkspace -scheme yourscheme -sdk iphonesimulator | ocunit2junit

  6. Use Python scripts for pgy uploads and notification messages send
    Add build step excute Shell
    python ${jenkins_home}/workspace/pgyupload/ pgydevupload.py
    Script can make the following modifications, making different versions of the resolution on different pgy on the same page
    if ' Jenkins-mncats-dev ' in Jenkins_build_number :
    Ukey = ' development key '
    _api_key = ' Development api '
    ProjectName = ' is the same as the project name you wrote in Jenkins, example: Xxx-dev '
    Print projectName
    PA SS
    If ' Jenkins-mncats-alpha ' in jenkins_build_number:
    Ukey = ' Alphakey '
    _api_key = ' Alphaapi '
    ProjectName = ' Same as the project name you wrote in Jenkins, example: Xxx-alpha '
    print projectName
    Pass
    If ' Jenkins-mncats-appstore ' in Jenkins_build_ Number:
    Ukey = ' AppStore version pgy key '
    _api_key = ' AppStore version API key '
    ProjectName = ' is the same as the project name you wrote in Jenkins, example: Xxx-ap PStore '
    Print projectName
    Pass

    def get_ipa_file_path ():
    Ipa_file_workspace_path = '/ users/yourname/jenkins/workspace/' +projectname+ '/build/' +projectname+ '. IPA '
    If os.path.exists (ipa_file_ Workspace_path):
    return ipa_file_workspace_path

OK, to this position we basically reached our goal, a little mouse every day, you can hand over the version of the work ~

Reference:
* http://www.jianshu.com/p/269d8d66472d
* Http://nickcheng.com/post/unique-icons-for-your-app-in-different-state-in-xcode5-debug-release

jenkins+cocoapods+pgy+ Multi-version Continuous Integration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.