Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash Travis CI,未找到文件,但它似乎存在_Bash_Shell_Unity3d_Travis Ci - Fatal编程技术网

Bash Travis CI,未找到文件,但它似乎存在

Bash Travis CI,未找到文件,但它似乎存在,bash,shell,unity3d,travis-ci,Bash,Shell,Unity3d,Travis Ci,我正在为我的Unity3d项目与Travis CI建立持续集成。到目前为止,在构建完成后,unity将该过程记录为成功,甚至打印出文件位置 统一代码: public static void BuildDevForAndroid() { List<string> scenes = new List<string>(); foreach (var s in EditorBuildSettings.

我正在为我的Unity3d项目与Travis CI建立持续集成。到目前为止,在构建完成后,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);
        }
但在Travis方面,我看不到dev\u 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\u BUILD\u APK\u PATH”
没有返回任何内容,就好像文件夹是空的一样。 Unity返回0,但找不到该文件

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

即使没有它我也很好,但我觉得这将是一个重新出现的问题,例如,当我尝试部署apk进行下载时会发生什么

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.