In the previous chapter, Jenkins (1) described Jenkins’ environment construction and installation of required plug-ins. In this chapter, we will talk about how to use these plug-ins to realize iOS automatic packaging and upload to itunesConnect, Dandelion, FIR and other platforms

1. Plug-in configuration

####1.1Keychains and Provisioning Profiles Management

1.2 Preparing Documents

Key string file (position in ~ / Library/Keychains/login keychain – db) package description file (position in ~ / Library/MobileDevice/Provisioning Profiles /) reach the file location on your own preferences, The key string file needs to be deleted before Jenkins can use it. It doesn’t matter what the name of the file is. Just find the one you need for your project and copy it.

1.3 Uploading files

The name of the developer certificate (find the name in the key string)

/ Users / {generally is the current user name} / Library/MobileDevice/Provisioning Profiles

Remember to click Save, or you’ll have to fill in the upload again

1.4 the xcode configuration

Go to Administration – System Settings and drop down to see Xcode Builder

2. Jenkins Project construction

2.1 Build Tasks

Enter the project name, select free style and click OK

2.2 the General configuration

The purpose of this step is to delete old items and avoid unnecessary memory usage

${name}, for example, ${Archive}

This time we first go back to the project interface build once, so that the above option configuration appears

2.3 Source Code Management

The Repository URL is the path to Jenkins’ pull code (accurate to the project location). If the Credentials are not available, click Add on the right, select Jenkins, and fill in your SVN account and password. Note that the user name in the URL address must be the same as the SVN account

2.4 Building an Environment

Note that when the Keychain and Provisioning profiles are initially checked, they are empty except for the Keychain and Provisioning Profiles that are valid. You only need to save and build once and the following image will appear

2.5 the xcode build

Build -> Add build steps -> Xcode click Settings, this step is not texturing, just fill in a few parameters, LET me explain and explain

2.5.1 General build settings

'Development Team'(Select package certificate)'Target'(If there are more than one project target to fill, otherwise ignore)'Clean before build'(Check, equal to xcode clean)'Configuration'(Compiled mode'Release'or'Debug')
'Xcode Schema File'(Project name)'Generate Archive'(Check whether Archive is retained)'Pack application, build and sign .ipa? '(Check, if not, the following parameters are not available)'Export method'(Packing method, unfortunately cannot use the above optional parameters, can only be filled'development'.'ad-hoc'.'enterprise' or 'app-store')'.ipa filename pattern'(IpA name after packaging, this is optional to fill, usually write the project name)'Output directory'Ipa output path, optional configuration, such as you can put on the desktop'/Users/{usually the current user name}/Desktop/APP')
Copy the code

2.5.2 Code signing & OS X keychain options

'Automatic Signing'(Don't bother to choose automatic configuration)'Read from Xcode Project'(Xcode is already configured, so select this to read)'Manual signing'(This is the manual selection of the description file) see the need to choose your ownCopy the code

2.5.3 Advanced Xcode build options

'Xcode Workspace File'(If it is the project of managing the third library project of POD, fill in the name of.xcworkspace and delete the suffix format)'Xcode Workspace File'(If it is not the project that manages the third library project of POD, fill in the name of.xcodeProj and delete the suffix format)Copy the code

At this point, xcode configuration is complete. At this time, we go to build once. After the build is successful, we can see some files after just filling in the IPA output path, as shown in the figure

2.6 Release to App Store and Dandelion

2.6.1 App Store

Since the Jenkins Xcode plugin does not support uploads to the App Store, we need to use shell scripts, add build steps, select shell and fill in the following

then
# upload appStore
altool="/Applications/Xcode.app/Contents/Applications/Application Loader.app/Contents/Frameworks/ITunesSoftwareService.framework/Versions/A/Support/altool"
"${altool}" --validate-app -f "Path of IPA"-u Developer account -p account password -t ios --output-format XML"${altool}" --upload-app -f "Path of IPA"-u Developer account -p account password -t ios --output-format XMLfi
Copy the code

In particular, since apple accounts have two-factor authentication, In addition, altool file not found may be required. Create a soft link for Altool. Open the terminal and execute ln -s /Applications/Xcode.app/Contents/Applications/Application\ Loader.app/Contents/itms /usr/local/itms

2.6.2 dandelion

See dandelion official website documents directly, there are detailed instructions to use methods

At this point Jenkins is done automating with plug-ins

Finally, I think this method is not free enough for automation, for example, the optional parameters I configured above are not used, and there are a series of unpleasant things like uploading dandelions without a log, so I think the plug-in form of automation is not cool enough. So I studied the Jenkins+shell+ Python approach to achieve iOS sustainable integration automation