Mac安装brew&jenkins&打包apk&ipa

https://www.zhihu.com/question/35928898?sort=created
https://www.jenkins.io/download/lts/macos/
https://www.cnblogs.com/panwenbin-logs/p/10856774.html 使用tomcat部署jenkins的war文件
https://www.cnblogs.com/zhanggui/p/6227832.html
https://zhuanlan.zhihu.com/p/40657950
http://mirrors.jenkins-ci.org/war/ jenkins的war文件下载地址
https://blog.csdn.net/qq_17347313/article/details/102806751 自动签名


我的jenkins是通过下载jenkins.war文件,然后按照jdk,通过java -jar jenkins.war启动的。
然后一直在loading界面,是通过修改:

Mac安装brew&jenkins&打包apk&ipa_第1张图片
这样才能顺利的进入jenkins。

windows下,需要进入:
C:\Users\user.jenkins
Mac安装brew&jenkins&打包apk&ipa_第2张图片
将https://updates.jenkins.io/update-center.json改为:
http://mirror.xmission.com/jenkins/updates/update-center.json

项目的路径设置:
Mac安装brew&jenkins&打包apk&ipa_第3张图片

Mac安装brew&jenkins&打包apk&ipa_第4张图片

#!/bin/sh
# unity app path
UNITY_PATH="/Applications/Unity/Hub/Editor/2019.2.1f1/Unity.app/Contents/MacOS/Unity"
# project path
PROJ_PATH="/Users/simingtu/Documents/KeyboadHeightDemo"
UNITY_LOG_PATH="/Users/simingtu/Documents/log.txt"
 
echo "============== Unity Build APK Begin =============="
"$UNITY_PATH" -projectPath $PROJ_PATH -executeMethod BuilderApk.BuildMyAndroidApk -logFile $UNITY_LOG_PATH -batchMode -quit
 
echo "============== Unity Build APK Finish =============="
exec /bin/bash 



无执行权限,在通过chmod 777 apk.sh
即可。

Mac安装brew&jenkins&打包apk&ipa_第5张图片

打包脚本:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

public class BuilderApk : Editor
{
    [MenuItem("BuildApk/BuildMyAndroidApk")]
    public static void BuildMyAndroidApk()
    {
        Debug.LogError(Application.dataPath);
        string outputPath = "/Users/simingtu/Documents/xx.apk";           //输出的安装包路径目录
        BuildOptions buildOption = BuildOptions.None;
        outputPath = outputPath.Replace('\\', '/');
        BuildPipeline.BuildPlayer(GetBuildScenes(), outputPath, BuildTarget.Android, buildOption);
    }

    static string[] GetBuildScenes()
    {
        List<string> pathList = new List<string>();
        foreach (EditorBuildSettingsScene scene in EditorBuildSettings.scenes)
        {
            if (scene.enabled)
            {
                pathList.Add(scene.path);
            }
        }
        return pathList.ToArray();
    }
}


打包ipa:
Mac安装brew&jenkins&打包apk&ipa_第6张图片
https://blog.csdn.net/qq_34241037/article/details/104995813
Mac安装brew&jenkins&打包apk&ipa_第7张图片

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

public class BuilderApk : Editor
{
    [MenuItem("Build/BuildMyAndroidApk")]
    public static void BuildMyAndroidApk()
    {
        Debug.LogError(Application.dataPath);
        string outputPath = "/Users/simingtu/Documents/xx.apk";           //输出的安装包路径目录
        BuildOptions buildOption = BuildOptions.None;
        outputPath = outputPath.Replace('\\', '/');
        BuildPipeline.BuildPlayer(GetBuildScenes(), outputPath, BuildTarget.Android, buildOption);
    }

    [MenuItem("Build/BuildMyIOSIpa")]
    public static void BuildMyIOSIpa()
    {
        Debug.LogError(Application.dataPath);
        PlayerSettings.iOS.appleEnableAutomaticSigning = true;
        PlayerSettings.iOS.appleDeveloperTeamID = "";
        //string outputPath = "/Users/simingtu/Documents/xx.apk";           //输出的安装包路径目录
        BuildOptions buildOption = BuildOptions.None;
        //outputPath = outputPath.Replace('\\', '/');
        BuildPipeline.BuildPlayer(GetBuildScenes(), "xxxxx", BuildTarget.iOS, buildOption);
    }

    static string[] GetBuildScenes()
    {
        List<string> pathList = new List<string>();
        foreach (EditorBuildSettingsScene scene in EditorBuildSettings.scenes)
        {
            if (scene.enabled)
            {
                pathList.Add(scene.path);
            }
        }
        return pathList.ToArray();
    }
}


构建ipa的脚本:

#!/bin/bash

#参数判断
if [ $# != 2 ];then
    echo "Params error!"
    echo "Need two params: 1.path of project 2.name of ipa file"
    exit
elif [ ! -d $1 ];then
    echo "The first param is not a dictionary."
    exit

fi


#工程路径
project_path=$1

#IPA名称
ipa_name=$2

#build文件夹路径
build_path=${project_path}/build


#编译工程
cd $project_path
xcodebuild || exit

#打包
cd $build_path
if [ -d ./ipa ];then
    rm -rf ipa
fi
mkdir -p ipa/Payload
cp -r ./Release-iphoneos/*.app ./ipa/Payload/
cd ipa
zip -r ${ipa_name}.ipa *
rm -rf Payload


到出xcode工程的sh脚本:

#!/bin/sh
 
#参数判断
package_name=xxxxx
 
#UNITY程序的路径#
UNITY_PATH=/Applications/Unity/Hub/Editor/2019.2.1f1/Unity.app/Contents/MacOS/Unity
 
#游戏程序路径#
PROJECT_PATH=/Users/simingtu/Documents/KeyboadHeightDemo
 
#IOS打包脚本路径#
BUILD_IOS_PATH=/Users/simingtu/Documents/buildios.sh
 
#生成的Xcode工程路径#
XCODE_PATH=${PROJECT_PATH}/$package_name
 
#将unity导出成xcode工程#
$UNITY_PATH -projectPath $PROJECT_PATH -executeMethod BuilderApk.BuildMyIOSIpa project-$package_name -quit
 
echo "XCODE工程生成完毕"
 
#开始生成ipa#
$BUILD_IOS_PATH $PROJECT_PATH/$package_name $package_name
 
echo "ipa生成完毕"

Mac安装brew&jenkins&打包apk&ipa_第8张图片

ipa是打出来了,但是不能安装到手机。估计是没有开发者账号的原因。

我这个是安装tomcat服务器之后,将打包好的文件拷贝到:
Mac安装brew&jenkins&打包apk&ipa_第9张图片
Mac安装brew&jenkins&打包apk&ipa_第10张图片

shell脚本内容为:

#!/bin/sh
# unity app path
UNITY_PATH="C:\Program Files\Unity\Hub\Editor\2019.2.1f1\Editor\Unity.exe"
# project path
PROJ_PATH="D:\OGL\KeyboadHeightDemo"
UNITY_LOG_PATH="D:\exe\BatunityApk_log.txt"
 
echo "============== Unity Build APK Begin =============="
"$UNITY_PATH" -projectPath $PROJ_PATH -executeMethod BuilderApk.BuildMyAndroidApk -logFile $UNITY_LOG_PATH -batchMode -quit
 
echo "============== Unity Build APK Finish =============="
cp -r D:/exe/xx.apk D:/software/apache-tomcat-7.0.105-windows-x64/apache-tomcat-7.0.105/webapps/download
echo http://localhost:8080/download/xx.apk
exec /bin/bash 

你可能感兴趣的:(jenkins)