Travis CI,找不到文件,但似乎存在

时间:2019-06-28 01:17:34

标签: bash shell unity3d travis-ci

我正在使用Travis CI为Unity3d项目设置持续集成。到目前为止,构建完成后,unity会成功记录该过程,甚至打印出文件位置。

统一代码:

        public static void BuildDevForAndroid()
        {
            List<string> scenes = new List<string>();
            foreach (var s in EditorBuildSettings.scenes)
            {
                scenes.Add(s.path);
            }
            string buildPath = "Builds/Android/Development";
            if (!Directory.Exists(buildPath))
                Directory.CreateDirectory(buildPath);

            Debug.Log("--Builder: BuildDevForAndroid: StartBuild");
            string buildName = GetBuildName();
            Debug.Log($"--Builder: BuildDevForAndroid: buildName {buildName}");
            var result = BuildPipeline.BuildPlayer(scenes.ToArray(), $"{buildPath}/{buildName}", BuildTarget.Android, BuildOptions.Development);
            Debug.Log($"--Builder: BuildDevForAndroid: build finished path = {result.summary.outputPath}");

            // HACK: Small Hack so we don't exit the editor on local machines 
            if (string.IsNullOrWhiteSpace(GetArg("buildName")))
                return;
            if (result.summary.result == BuildResult.Succeeded)
                EditorApplication.Exit(0);
            else
                EditorApplication.Exit(1);
        }

结果日志:

--Builder: BuildDevForAndroid: build finished path = /Users/travis/build/Austin47/ProjectPhotoAR_UnityClient/Builds/Android/Development/dev_travis.apk

但是在特拉维斯方面,我看不到dev_travis.apk

这是build.sh

#! /bin/sh

PROJECT_PATH=$(pwd)
UNITY_BUILD_DIR=$(pwd)/Build
LOG_FILE=$UNITY_BUILD_DIR/unity-android.log
UNITY_BUILD_APK_NAME=dev_travis.apk
UNITY_BUILD_APK_PATH=$PROJECT_PATH/Builds/Android/Development
UNITY_BUILD_APK=$UNITY_BUILD_APK_PATH/$UNITY_BUILD_APK_NAME

ERROR_CODE=0
echo "Items in project path ($PROJECT_PATH):"
ls "$PROJECT_PATH"

echo "Building project for Android..."
mkdir $UNITY_BUILD_DIR
/Applications/Unity/Unity.app/Contents/MacOS/Unity \
  --args buildName $UNITY_BUILD_APK_NAME \
  -batchmode \
  -nographics \
  -silent-crashes \
  -logFile \
  -projectPath "$PROJECT_PATH" \
  -buildTarget "Android" \
  -username "$UNITYEMAIL" \
  -password "$UNITYPASSWORD" \
  -serial "$UNITYKEY" \
  -executeMethod "Infrastructure.EditorHelpers.Builder.BuildDevForAndroid" |
  tee "$LOG_FILE"

echo "Items build folder ($UNITY_BUILD_APK_PATH):"
ls "$UNITY_BUILD_APK_PATH"

if [ $? = 0 ]; then
  if [ -e "$UNITY_BUILD_APK" ]; then
    echo "Building Android apk completed successfully."
    ERROR_CODE=0
  else
    echo "Building Android apk failed. Apk not found, check logs for possible build failure."
    ERROR_CODE=1
  fi
else
  echo "Building Android apk failed. Exited with $?."
  ERROR_CODE=1
fi

echo "return license"
/Applications/Unity/Unity.app/Contents/MacOS/Unity -quit -batchmode -returnlicense

#echo 'Build logs:'
#cat $LOG_FILE

echo "Finishing with code $ERROR_CODE"
exit $ERROR_CODE

以下是我返回的重要日志:

Items build folder (/Users/travis/build/Austin47/ProjectPhotoAR_UnityClient/Builds/Android/Development):
Building Android apk failed. Apk not found, check logs for possible build failure.
return license
Finishing with code 1
The command "./travis-build/build.sh" exited with 1.

ls "$UNITY_BUILD_APK_PATH"没有返回任何内容,好像文件夹为空。 Unity返回0,但是找不到文件。

我最终删除了该条件,主要是因为如果构建失败,则unity将返回1,因此可以说该检查是不必要的。

即使没有它我也没事,我感觉这将是一个将再次浮出水面的问题,例如,当我尝试部署apk以进行下载时,将会发生什么。

0 个答案:

没有答案