Build a sustainable integration environment for iOS projects with Jenkins (continuous integration abbreviation CI)

Source: Internet
Author: User

Objective

There are a lot of related blogs about Jenkins online, which is not repeated here. The new company to build the environment, I also refer to the following blog:http://www.jianshu.com/p/41ecb06ae95f said in detail and no longer elaborate. Of course in the actual construction also met a lot of pits, so close up this blog to supplement.

1. Initial Password Acquisition

Command line: cd/users/shared/jenkins/home/to the current directory, modify the/secrets/directory permissions after using the VIM editor to open the Initialadminpassword file can be copied inside the password.

2. Build the certificate configuration for your environment

Building a certificate environment requires uploading keychain and Provisioning profile files: The keychain file contains the code signing files required for packaging, and Provisioning profile is the device file. The signature files and device files can be obtained from the Developer Account Center and then installed on this computer. Open keychain Access, create a new empty keychain on the desktop, and then copy the installed signature file (including development certificate and publishing Certificate) from the Keychain-login item to the new keychain and set the keychain password so that the keychain and device files are ready and then uploaded directly to the Jenkins server. Once the upload is successful, you can select the specified certificate in the build environment configuration of the new Jenkins Project.

3. Build Scripts

The build process can choose the way Xcode and script, using Xcode to install plug-ins, here choose to execute the script "compile-package-export ipa-upload to Dandelion". Xcodebuild + Xcrun is used in the reference blog post to verify that Xcrun is marked as obsolete after Mac OS 10.12 and is manually built with Jenkins, so you can do all the work directly with Xcodebuild in the new Mac OS. Here is the script I wrote when I tested it:

# project Name App_name="Jenkins-demo1"# Certificate (code_sign_distribution), this section can not be used, because the certificate has been configured #code_sign_identity="IPhone Developer: ~ ~ ~"#PROVISIONING_PROFILE_SPECIFIER="~~~~~~~~~~~~~~~~"# info.plist Path Project_infoplist_path="./${app_name}/info.plist"# Get Versionbundleshortversion=$(/Usr/Libexec/Plistbuddy-c "Print cfbundleshortversionstring" "${project_infoplist_path}")# Get Buildbundleversion=$(/Usr/Libexec/Plistbuddy-c "Print Cfbundleversion" "${project_infoplist_path}")# date Ipa_date="$ (date +%y%m%d)"# ARCHIVE Name #archive_name="${app_name}_v${bundleshortversion}_${ipa_date}.xcarchive"# IPA Name #ipa_name="${app_name}_v${bundleshortversion}_${ipa_date}.ipa"# Archive and IPA storage directory Archive_ipa_cache_path="$HOME/jenkinsipas/${ipa_date}"# archive Path Archive_path="${archive_ipa_cache_path}/${app_name}.xcarchive"# IPA path Ipa_path="${archive_ipa_cache_path}"echo ${archive_path}echo ${ipa_path}# cleanecho"-------------Clean-------------"Xcodebuild-target"${app_name}"-configuration' Release 'clean# Buildecho"-------------build-------------"Xcodebuild-target"${app_name}"-SDK iphoneos-configuration' Release '# Archive
Echo"-------------Archive-------------"
#xcodebuild Archive-project ${app_name}.xcodeproj-scheme ${app_name}-archivepath ${archive_path}# Get exportoptionsplistpath path Exportplist_path="./${app_name}/exportdevelopment.plist"# Export Ipaecho"-------------Export IPA-------------"#xcodebuild-exportarchive-archivepath ${archive_path}-exportoptionsplist ${exportplist_path}-Exportpath ${ipa_path}# upload to dandelion Echo"-------------upload to Pgyer"#UserKey and Apikeyuser_key="c064020a03b0f19cccd3fd82f143cf76"Api_key="B5f849b038e3761c09b25e03ff1e3c71"#curl-F"[Email Protected]${ipa_path}/${app_name}.ipa]-F"Ukey=${user_key}"-F"_api_key=${api_key}"Https//Www.pgyer.com/apiv1/app/upload

Issues to be aware of:

    • The above command in the test when the proposed step-by-step, first compiled and then packaged finally exported IPA, so that in error, easy to troubleshoot and timely correction.
    • Use the-archivepath parameter must use the-scheme parameter, otherwise Jenkins will be built when the error can not find scheme, under normal circumstances a project only one scheme and the name and project name the same, After using the-scheme parameter after the build test or will error is because scheme default is private, can be selected in the project manage schemes "Shared", and then submitted to the Code warehouse, Jenkins rebuilt without error.
    • Export the IPA when you need to use the-exportoptionsplist parameter, specify a plist file, configuration method can be consulted:http://www.cocoachina.com/ios/20170607/19464.html or http://www.jianshu.com/p/bd4c22952e01 or http://blog.csdn.net/offbye/article/details/. The 51506256 configuration will not have an error if you specify the correct plist path.
    • UserKey and Apikey are required when uploading to dandelions, and these 2 parameters can be obtained from the Dandelion account.
At last

The reader can install the Jenkins environment on his or her computer, create a public code base on the Gitlab, create an empty project locally and upload it to the codebase, and specify that the library address be tested for the remote warehouse address that was automatically pulled when Jenkins was built. Of course, in the process of building may still encounter some pits, do not fret, calm down and try to solve their own, there will always be a way. More practice, more reference, there will always be some harvest.

Build a sustainable integration environment for iOS projects with Jenkins (continuous integration abbreviation CI)

Related Article

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.