[Open source tools] [Unity practice] How to configure Jenkins to pull Git/Jenkins and use Unity for one-click packaging [windows][android]

1. Background introduction

1.1What is Jenkins?

Insert image description here
Jenkins official website is an open source CI&CD (continuous integration & continuous deployment) software used to automate various tasks, including building, testing and deploying software.

Easy installation: Jenkins is a standalone Java-based program that runs out of the box on Windows, Mac OS X, and other Unix-like operating systems. Jenkins supports various running methods, either through system packages, Docker or through a standalone Java program.

Plug-in extensions: With more than 1,000 plug-ins in the update center, Jenkins integrates almost all tools in the continuous integration and continuous delivery tool chain. And Jenkins is extensible through its plug-in architecture, providing nearly unlimited possibilities for what Jenkins can do.

Distributed: Jenkins can easily distribute work across multiple machines, helping drive builds, tests, and deployments across multiple platforms faster.

CI&CD: As a scalable automation server, Jenkins can be used as a simple CI server or turned into a continuous delivery hub for any project.

Tsinghua Jenkins download

1.2 What are the benefits of using Jenkins+Unity?

In layman's terms, it means that the repetitive packaging work is handed over to the computer, freeing the programmer, and the program can directly look at the packaging results.
Insert image description here

2.Jenkins installation & use

The windows environment + tomcat deployment I use

2.1Java11

java11 download
Insert image description here

Insert image description here
Insert image description here

Insert image description here

2.2 Download jenkins.war (I use tomcat so I need it, you can use jenkins to install the version)

Jenkins.war
Insert image description here

2.3 Using Tomcat9

Download Tomcat9
Insert image description here
and extract it to the path:
Insert image description here

2.4 After decompressing tomcat9, put jenkins.war into

Insert image description here
Insert image description here

2.5 Double-click to run startup.bat -> include jenkins

Insert image description here
Solving the Chinese garbled
Insert image description here
tomcat9 with jenkins will have the initial password of jenkins
Insert image description here

2.6 Copy the text and visit localhost:8080/jenkins

Insert image description here
Insert image description here

Insert image description here
Insert image description here
Insert image description here
Insert image description here

3.Jenkins pulls Git

Insert image description here

Insert image description here
Insert image description here

4. Jenkins configures Unity packaging (direct command line, without the unity3d plug-in)

4.1 github project-jenkins_unity

4.2windows-bat packaging…

Insert image description here

4.3 Core packaging.cs

using System;
using UnityEditor;

class MyEditorScript {
        [MenuItem ("Custom/CI/Build Android")]
        public static void BuildAndroid()
        {
            string[] scenes = { "Assets/Scenes/SampleScene.unity"}; // 填写您的场景文件路径
            string outputPath = "Builds/Android/JenkinsUnity.apk";
            
            BuildPipeline.BuildPlayer(scenes, outputPath, BuildTarget.Android, BuildOptions.None);
        }
}

Insert image description here
Insert image description here
Insert image description here

5. [Recommended] Use the Unity3d plug-in package that comes with Jenkins to output complete logs

Here is a reference to my friend TopGames’ blog
Insert image description hereInsert image description here

Add parameters: ProjectRoot

and then configure the built-in unity3d plug-in in Jenkins.
Insert image description hereAfter installing the unity3d plug-in,
Insert image description hereopen the global tool configuration as shown in the figure
Insert image description hereInsert image description here. Now return to the project configuration:
Insert image description hereCopy the following content:
Insert image description hereClick to run:
Insert image description here
the console will print the complete unity log.
Insert image description here

6.TODO pull Git+Unity package and merge processing, to be continued

Guess you like

Origin blog.csdn.net/aaaadong/article/details/130722102