(Plug-in) for automatic packaging using Jenkins + unity + xcode.

Source: Internet
Author: User

I recently learned about Jenkins's process-based services. I personally think Jenkins is a very convenient tool, mainly for convenience, and has set the process-based commands. Automation can be achieved only after confirmation. Reduces errors and simplifies complex steps. Today, we will take Jenkins as an example to compile unity to generate an APK package and an IPA file.

It usually requires cooperation between teams to build a project. If you plan to develop a test package on your own, you need to seek help from you, interrupt your work, and compile a package specially. If you already have a Jenkins server, you can get the desired package through simple operations, there is no need to bother you with completing these tedious steps step by step.


Here I wrote a document about Jenkins and unity.To stamp it here

Post it first.

First of all, Jenkins is a Java-based tool for processing the service nature of a process.

Disadvantage: complicated configuration advantages: You can execute. Sh scripts and many plug-ins.

(I use a Mac computer, so I can directly download Jenkins for Mac and install Jenkins on the Internet)

 

1. Preparations: In the unity project, we create a script under assets/editor to execute compilation. For example, mongombuild. cs. For specific code, see the file in the file. The main function is to use code for packaging.

2. Install Jenkins (for the installation package file, see the folder) Step by step. It will automatically start Jenkins.

3. Start to use Jenkins. The menu on the left is "new" and "task history.

In order to do this, we first set up the following users. Click "System Management"> "configure global security" in the left-side menu bar and click "enable security". "security domain": click "Jenkins Apsara stack user database" to allow user registration. Authorization Policy: select-any user can do anything and save it. Return to the main interface and register the user in the upper right corner. Register step by step.

4. Return to the main interface, click "new" on the left-side menu bar, write the item name (project name), select "Create a free-style Software Project", and click "OK" to configure the project.

5. before configuring the project, download several plug-ins. Go back to the main interface, click system management in the left-side menu bar, Click Manage (selected), and enter the unity3d plugin, xcode integration, git plugin, gitlab hook plugin. use-download and install Jenkins, and restart Jenkins. The command is http: // localhost: 8080/restart.

6. note that we use a Mac computer and have high permission requirements. Jenkins is installed in/users/shared/Jenkins/home by default, the workspace directory of Jenkins is also in the directory. This is a very sensitive directory and requires frequent operations, which may cause many errors that cannot be found. We can use terminal to change directory permissions, which is very troublesome (discard ). We can also use the slave node of Jenkins to direct the working directory to the outside. Operation:

Go back to the main interface-system management-manage nodes-create a node, for example, the node name is unity4.5, select dumb slave, and click OK. Then configure the next node. # Of executors: the number of concurrent operations. The default value is 1. Remote Directory: for example,/users/Vika/desktop/unity_prt/autobuild is equivalent to the main directory. After the directory is executed, it will automatically create a subdirectory (/workspace/project name /) (Come back and put the unity project file below ).

Usage: select-use this node whenever possible. Start method:

Launch slave agents via Java Web Start, Which is started by the slave command. Availability: Keep this slave on-line as much as possible, keep slave dos enabled. Save and return to the management node. Click the newly created unity4.5 node to see that the node is not started. We must use slave. Jar (see the folder) to start it. Open terminal to slave. use the jar folder (Java-jar slave. jar-jnlpurl http: // localhost: 8080/computer/unity4.5/slave-agent.jnlp) command to start the unity4.5 node. Go back to Jenkins and refresh the node. We can see that the node unity4.5 has been started.

7. Return to the main interface, click the project we created, and click-configuration in the left-side menu. Start configuring our project.

From top to bottom, in sequence-project name (unchanged),-description (can be left blank),-discard the old build (can be set, how much time to clean up the old build ), you can set it as needed. Finally, you can see the restrict where this project can be run: select the newly created unity4.5.

Advanced options: useless for the moment.

Source code management: There are several methods, including the plug-in git we just downloaded, as well as CVS and SVN. If it is local, select none.

Build a trigger: (trigger the conditions for project building). There are several methods:

Remote trigger: Set the token to use URL for construction.

Pollscm: time triggers can be set to control and automatically built. The remaining two are not commonly used.

Build: click Add build step. We are a unity project. Select invoke unity3d Editor, which has two titles: unity3d installation name. You need to select

(If it is not saved first, go back to the main interface,-system management-system settings-unity3d, and set the unity3d installation directory,/applications/Unity. app. You can create an alias and save it. Then, return to project-configuration ),

Editor command linearguments: the DOS command used to execute the unity command line. What I wrote here is (-Quit-batchmode-executemethod implements mbuild. commandlinebuildandroid) You can understand that the commandlinebuildandroid method is executed in the editor directory of the project. There will be a question here. After this is done, how does Jenkins know my project directory? Here, unity3d plugin is in the default Jenkins directory (workspace/project name, therefore, you have two options: Copy your project to the (workspace/project name) directory, or add the-projectpath command before dos. Copy to workspace. The commandlinebuildandroid method is used to compile Android. If you still need to compile iOS, click-add build step and set it in sequence according to the above method.

We have set the unity part. Now we have the APK and xcode projects. Next we will set up the xcode compilation project. Click-add build step-xocde.

General build settings: Target (do not write), click-settings, clean before build Select Yes, and you do not have to select the remaining one. configuration has two modes: Release and debug, depending on the situation you choose.

Pack application and build. IPA: No, we use the command to pack.

 

Code signing & OS X keychain options: code signing identity (this is a certificate, the protocol has to be selected, you can open an xcode project at will to search for code signing identity in the build settings of the project, you can see the certificate, for example, iPhone developer: Something (certificate serial number), and write the certificate. Embedded profile: Embedded configuration file (none can be left blank ).

Unlock keychain: Set it by yourself.

Advanced xcode build options: Here is the directory for setting the xcode project. We are the unity directory. Many of them do not need to be set here. xcode project directory settings. Note that the directory is relative to the workspace directory, example :.. /build/iPhone. SDK: iphoneos7.1. This is the compiled SDK and is set to 7.1. Don't worry about the rest.

After compiling xcode, we need to set up and package IPA here. Click-add build step-execute shell. Here is the shell script. The command for packaging the. app file is :(

Xcrun-SDK iphoneos7.1packageapplication-V/users/user name/desktop/unity_prt/autobuild/workspace/build/iPhone/build/autobuild. app-O/users/user name/desktop/unity_prt/autobuild/workspace/build/iPA/autobuild. IPA

), Use xcrun for packaging.

 

To move the packaged file and APK from the project directory, run the CP command. (

CP-P/users/user name/desktop/unity_prt/autobuild/workspace/build/Android/autobuapps.apk/users/Vika/desktop/FTP/

)(

CP-P/users/user name/desktop/unity_prt/autobuild/workspace/build/iPA/autobuild. iPA/users/Vika/desktop/FTP/

)


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.