IOS uses Jenkins for continuous integration and iosjenkins
This article mainly describes the continuous integration of IOS-Jenkins during the development process to improve work efficiency.
Background
We usually develop IOS projects and package them to testers for testing. The process must be repeated: modify the configuration item -- compile -- connect to the device -- run the package -- debug into the device -- and then hand it to the waiting tester. The existing mature continuous integration Jenkins solution also provides support for Xcode plug-ins. You can talk about the above process as a one-click solution.
I implemented jenkins to execute the IOS job, build the project, sign the ipa package, upload it to the FTP server, put it under tomcat, and provide http download and install app.
Process
1. Download and install jenkins
Address: https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins#InstallingJenkins-Unix%2FLinuxInstallation
The downloaded war package (Background Service) requires jdk.
Click jenkins. war to run the command. visit http: // localhost: 8080 /.
You can also run java-jar jenkins. war -- httpPort = 8888; http: // localhost: 8888/
You can also put it under tomcat.
After running, A. jenkins directory is created under user.
2. added the Xcode plug-in.
In jenkins system management, find the management plug-in, search for xcode under the optional plug-in tab, check the installation, install the plug-in/upgrade, and wait for jenkins to upgrade to the latest version, xcode plug-in is better installed (if it fails, download the latest jenkjins, or try multiple times ).
In this way, jenkins will be restarted, and the xcode support options will be displayed in the drop-down menu of the job building.
3. Create a job
Create a free job.
4. Source Code Management
If svn is used, select subversion and direct it to the address. If svn is not used, select none to run the job first, in this way, the jenkins working directory creates a failed job. The directory is. jenkins/jobs/your job name /. At this time, there are directory files under the job, such as builds and workspace. What we need is to put our code project into the workspace (this is the official solution ).
For the directory structure, see.
In this way, the Code is available in the workspace.
5. Build the xcode Project
Select xcode from the Add building step drop-down list.
For example, if you configure parameters in a simple way, execute the target of the project, and set Configuration to Debug (select Release as needed), there is a Pack application and build. ipa option below, which is not selected.
There is also a Code signing and key chain option below. If this option is left blank, the default option will be automatically found (it is configured in the project. You can see the execution log in the runtime console, what will be done in each step in the output ).
There is an xcode advanced parameter configuration below,
Scheme configuration and SDK to be built and run. Here, select iphoneos (this is to be prepared to run on a real machine) and the build output directory.
Let's talk about the simulator here. It cannot be configured as an iPhone simulator because it is useless and the simulator cannot run. First, the apple unix Command can start the simulator, however, no api is provided to install the ipa Program in the simulator and run it (the xcodebuild command does not support this function). I found a solution online and found that it was a long time ago, four years ago, there was a github plug-in, but this plug-in project was dependent on iPhoneSimulatorRemoteClient. framework library, but the current mac can not find this library, so it cannot run, so the command line to start the simulator, and install and run ipa method is not good, only the real machine method is available.
Run the job. The current directory file should appear. The ipa is still running.
Now, it means that jenkins's IOS job can be basically OK.
6. Then we will package the ipa file.
I did not select the above xcode to configure pack application and build ipa. I haven't figured it out yet. Its output directory context is changed to jenkins, the generated ipa is a hidden directory in the xcode installation directory, which is not clear yet.
I am using shell and command line.
Select Add building step, click shell, and a command line input box appears, as shown in the figure below.
Follow the commands shown in the figure and select the sdk package app to specify the output directory file. After the build is complete, the ipa file in the directory structure appears. This is the installation program we need, it can be installed on a real machine after being signed. For details about the commands for adding signatures and descriptions, refer to the xrun command description.
OK, we have completed a big step.
7. Now let's set up the ftp upload function.
Mac itself supports the ftp service and finds a convenient software for modifying the system, lion tweaks,
Find ftp on the right and enable it.
We need to set the jenkins system configuration-the system management link is on the left side of the root path, click it, and select system settings to find the FTP configuration item, as shown in the figure below:
I set my own computer, so localhost is gone. Set the ftp root path root repository path and enter the user name and password of the local machine.
Set the ftp service for your job,
As shown in the figure, set the files to be uploaded and their corresponding directories. Now, for uploading ipa Program files, we need to upload the generated ipa files in the build directory to a directory on the ftp server, we uploaded the files to the tomcat directory for subsequent mobile phone downloads through the tomcat service.
This directory structure is available under tomcat after the upload is successful, as shown in the figure below:
In this way, we can upload files to the ftp server.
8. Tomcat Service
Then we need to set up the tomcat service so that our mobile phone can download and install our application on the webpage.
Download tomcat, go to the bin directory of tomcat, and execute the command,
Sh startup. sh
Start tomcat.
Create a simple web project. For more information, see the web implementation and put it under tomcat's webapps. Modify tomcat's access port 8088, which is in conflict with jenkins8080, so when we access tomcat,
You can access our project, http: // localhost: 8088/hello_jenkins2/index. jsp.
9. Download supported files
Now we will describe how to upload the ftpfile of our jenkinsjob. ios_down.html provides a webpage. You can click a link to download the installer to your mobile phone. The relative hello_jenkins.plist file supports downloading ipa files to mobile phones.
The ios_down connection protocol points to this plist,
<A href = "itms-services ://? Action = download-manifest & url = http: // 192.168.200.124: 8088/hello_jenkins2/publish/hello_jenkins.plist ">
This hello_jenkins.plist describes and points to ipa
The content is as follows:
<? Xml version = "1.0" encoding = "UTF-8"?>
<! DOCTYPE plist PUBLIC "-// Apple // dtd plist 1.0 // EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<Plist version = "1.0">
<Dict>
<Key> items </key>
<Array>
<Dict>
<Key> assets </key>
<Array>
<Dict>
<Key> kind </key>
<String> software-package </string>
<Key> url </key>
<String> http: // 192.168.200.124: 8088/hello_jenkins2/static/build/Debug-iphoneos/HelloJenkins. ipa </string>
</Dict>
</Array>
<Key> metadata </key>
<Dict>
<Key> bundle-identifier </key>
<String> com. hai. HelloJenkins </string>
<Key> bundle-version </key>
<String> 1.0 </string>
<Key> kind </key>
<String> software </string>
<Key> subtitle </key>
<String> HelloJenkins </string>
<Key> title </key>
<String> HelloJenkins </string>
</Dict>
</Dict>
</Array>
</Dict>
</Plist>
In this example, When you browse the Web page ios_down.html, click the install label above to point to the hello_jenkins.plist file, parse the file and locate the ipa file. The mobile phone also prompts you to download and install hello_jenkins. Download and install it.
10. Complete
Mobile Access
Http:/// 192.168.200.124: 8088/hello_jenkins2/publish/ios_down.html
I have already installed it on my mobile phone, so I will not send a picture.
11. Finally, pay attention to some issues
Note the path problem. If the job's ftp File Upload path, html file and plist file path are a bit wrong, it will cause problems such as access failure and download failure.
Pay attention to the compatibility between the base sdk of the installation program and the real machine. Otherwise, the installation program will not be able to be installed.
Note that the ftp upload directory is based on the user directory set by our system.
In addition, if the directory of the uploaded file is not correct, jenkins does not report an error, and the output log prompts not found file, so check the job log.
In addition, sometimes the plist file is correct but cannot be accessed. Please try to copy a copy of another plist file. In the modification content, I have seen, copy one copy.
Ps:
There are not many such aspects on the Internet. I have spent some time studying and devoted myself to everyone. I still have some questions and I will add them later.
How to Use jenkins for continuous integration in common java Projects
1. Define the pom. xml file of maven. There is too much content to define in pom. search online.
2. submit the project to the version library for software management, such as svn
3. In the jenkins checkout project, define maven to execute commands, such as maven package
Jenkins can only perform continuous integration.
You don't need continuous integration. You can also use it to automatically start build or test. It is equivalent to an automated execution engine. You can use it for specific purposes.