This project demonstrates how to set up continuous integration for a Unity project using Jenkins.
- Jenkins - Installed and running on your machine
- Unity Hub - With at least one Unity version installed
- Git - For version control
UnityProject/- The Unity project directoryAssets/- All Unity assetsEditor/- Editor scriptsBuildScript.cs- Build script for Jenkins
Jenkinsfile- Jenkins pipeline definition
-
Install Required Plugins:
- Unity3d Plugin
- Git Plugin
- Pipeline
- Credentials Binding Plugin
-
Configure Unity in Jenkins:
- Go to Manage Jenkins > Global Tool Configuration
- Add a new Unity installation
- Set the path to your Unity executable (e.g.,
/Applications/Unity/Hub/Editor/[Version]/Unity.app/Contents/MacOS/Unity)
-
Create a New Pipeline Job:
- Create a new Pipeline job
- Set the Pipeline definition to "Pipeline script from SCM"
- Select Git as the SCM
- Enter your repository URL
- Set the script path to
Jenkinsfile
You can trigger a build locally using the Unity command line:
/Applications/Unity/Hub/Editor/[Version]/Unity.app/Contents/MacOS/Unity \
-batchmode \
-nographics \
-quit \
-projectPath /path/to/UnityProject \
-executeMethod BuildScript.PerformBuild \
-logFile build.log \
-buildTarget StandaloneOSX \
-buildPath "Builds/Build"- Unity not found: Update the
UNITY_PATHin the Jenkinsfile to match your Unity installation path. - Build failures: Check the Jenkins console output and the Unity log file for detailed error messages.
This project is open source and available under the MIT License.