GithubHelp home page GithubHelp logo

hsl9999 / unity-jenkinsfile Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vad37/unity-jenkinsfile

0.0 0.0 0.0 323 KB

auto copy paste personal script for jenkin pipeline to project from unity

Shell 3.03% Ruby 3.87% Python 63.81% C# 24.84% PowerShell 4.46%

unity-jenkinsfile's Introduction

Unity Jenkinsfile

Note: Currently this project is used for internal-team at my work place. There might some missing doc and setup not included and project is in development.

Although it is ready to run with any random project. Work for both building simple Android and fastlane build for iOS. Just drag these files in and it will run on your Jenkins Server.

Multi-branch Jenkinsfile and python script for automated Android build Production: Install Unity -> Build Unity --> Push to internal Google Play -> Send Slack notification.

Made specifically for Windows Standalone Server. (Meaning no special install and setup for server. Just install jenkins setup some system variables and it will ready to go). With MacOSX, there are lots of special steps to setup fastlane, allow open ssh port with jenkins. You have to figure out on your own.

Read pipeline doc for how to setup UnityProject builder script.

Install

Simply copy this entire project to root .git folder. Jenkins only need to detect Jenkinsfile in root folder.

git clone https://github.com/VAD37/unity-jenkinsfile.git

Setup Jenkins Server

Due to limitation of Docker and Unity Linux during this project was made. It was much easier to build Unity on Windows.

IMPORANT must install mingw64 as bash shell in Windows. If you dont know what is Mingw is, it is the same as Git Bash.

You can install mingw64 or git bash through Chocolatey for best result.

Windows Jenkins will not run git command with any other Linux shell like Window-Linux or cygwin due to Different in window directory path.

Install python on all build agents.

Go into jenkins settings/ Manage Nodes and set all agents with tags "Windows" so pipeline will run when finding agents. (remove agents option from Jenkinsfile if you dont want to use tags)

Enviroment Variables Requirements

IMPORANT Make sure git Bash or mingw64 bash.exe be on top in Path environment. Other linux shell command can still be accessible when use in pipeline. After reset environment. Restart server. (This was required due to conflict between '' and '/' in old window-jenkins version)

sapmple

JAVA_HOME : Required for android build. Just install newest Java JDK

UNITY_INSTALL_LOCATION : default to C:\\Program Files\\Unity\\Hub\\Editor (Required to find Unity path)

UNITYHUB : default to C:\Program Files\Unity Hub\Unity Hub.exe (Required to install missing Unity version through Hub)

Helpful tips

For setting up project password and pre-build function use IPreprocessBuildWithReport

using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEditor.AddressableAssets.Settings;
using UnityEditor.Callbacks;
using UnityEngine;


public class BuildProcessor : IPreprocessBuildWithReport {
    
    [PostProcessBuild(1)]
    public static void DeleteDebugPrefabInResources(BuildTarget target, string pathToBuiltProject) {
        Debug.Log( pathToBuiltProject );        
    }

    public int callbackOrder { get; }
    public void OnPreprocessBuild(BuildReport report)
    {
        var pipeline = Builder.Configs["PIPELINE"];
        // 3 type of pipelien: production, develop, internal
        if(pipeline != "production") 
        {
            // Add develop prefab to resource or create readable file in resources
        }
        
        
        PlayerSettings.Android.useCustomKeystore = true;
        PlayerSettings.Android.keystoreName      = "Path to keystore file in project. The same one as in Editor";
        PlayerSettings.Android.keyaliasName      = "";
        PlayerSettings.Android.keyaliasPass      = "";
        PlayerSettings.Android.keystorePass      = "";
        PlayerSettings.Android.minSdkVersion     = AndroidSdkVersions.AndroidApiLevel19; // minium API for override adb install to work with        
        AssetDatabase.SaveAssets();
		
		AddressableAssetSettings.BuildPlayerContent();
    }
}

Search these Jenkins server plugins: All Blue Ocean, Job DSL, Pipeline, PowerShell

Set Always scan with interval 1 minute.

In jenkins server installation folder. Change jenkins.xml line to this. (extra file size limit)

<arguments>-Xrs -Xss4m -Xmx1024m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpListenAddress=127.0.0.1 --httpPort=8080 --webroot="%BASE%\war" --prefix="/jenkins"</arguments>

https://stackoverflow.com/questions/39340322/how-to-reset-the-use-password-of-jenkins-on-windows

When create new multi-branch pipeline. Set Git setting to this. git

unity-jenkinsfile's People

Contributors

vad37 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.