Silenc3e3e
Silenc3e3e

Reputation: 17

Troubleshoot Unity not building in Travis CI

I've set up Travis CI with my GitHub repo, which holds my Unity project, and it currently automatically attempts to build my projects, but has so far not succeeded once. After much fiddling, research and troubleshooting, it now reaches the point where Travis successfully downloads and installs the files needed (Yay! Progress), but it gets stuck in the build. This is the ouput

Attempting to build GodGame for Windows

No output has been received in the last 10m0s, this potentially indicates a stalled build or something wrong with the build itself.

Check the details on how to adjust your build configuration on: https://docs.travis-ci.com/user/common-build-problems/#Build-times-out-because-no-output-was-received

The build has been terminated

My .travis.yml has

language: objective-c
osx_image: xcode8.1
rvm:
- 2.2
before_install:
- chmod a+x ./Script/install.sh
- chmod a+x ./Script/build.sh
install:
- ./Script/install.sh
script:
- ./Script/build.sh

My install.sh has

#!/bin/sh

BASE_URL=http://netstorage.unity3d.com/unity
HASH=46dda1414e51
VERSION=2017.2.0f3

download() {
  file=$1
  url="$BASE_URL/$HASH/$package"

  echo "Downloading from $url: "
  curl -o `basename "$package"` "$url"
}

install() {
  package=$1
  download "$package"

  echo "Installing "`basename "$package"`
  sudo installer -dumplog -package `basename "$package"` -target /
}

# See $BASE_URL/$HASH/unity-$VERSION-$PLATFORM.ini for complete list
# of available packages, where PLATFORM is `osx` or `win`

install "MacEditorInstaller/Unity-$VERSION.pkg"
install "MacEditorTargetInstaller/UnitySetup-Windows-Support-for-Editor-$VERSION.pkg"
install "MacEditorTargetInstaller/UnitySetup-Mac-Support-for-Editor-$VERSION.pkg"
install "MacEditorTargetInstaller/UnitySetup-Linux-Support-for-Editor-$VERSION.pkg"

And my build.sh has

#!/bin/sh

project="GodGame"

echo "Attempting to build $project for Windows"
/Applications/Unity/Unity.app/Contents/MacOS/Unity 
  -batchmode 
  -nographics 
  -silent-crashes 
  -logFile $(pwd)/unity.log 
  -projectPath $(pwd) 
  -buildWindowsPlayer "$(pwd)/Build/windows/$project.exe" 
  -quit

echo "Attempting to build $project for OS X"
/Applications/Unity/Unity.app/Contents/MacOS/Unity 
  -batchmode 
  -nographics 
  -silent-crashes 
  -logFile $(pwd)/unity.log 
  -projectPath $(pwd) 
  -buildOSXUniversalPlayer "$(pwd)/Build/osx/$project.app" 
  -quit

echo "Attempting to build $project for Linux"
/Applications/Unity/Unity.app/Contents/MacOS/Unity 
  -batchmode 
  -nographics 
  -silent-crashes 
  -logFile $(pwd)/unity.log 
  -projectPath $(pwd) 
  -buildLinuxUniversalPlayer "$(pwd)/Build/linux/$project.exe" 
  -quit

echo 'Logs from build'
cat $(pwd)/unity.log


echo 'Attempting to zip builds'
zip -r $(pwd)/Build/linux.zip $(pwd)/Build/linux/
zip -r $(pwd)/Build/mac.zip $(pwd)/Build/osx/
zip -r $(pwd)/Build/windows.zip $(pwd)/Build/windows/

If it helps, here is my .gitignore. Is there maybe a line in here I need to remove?

###
# Unity folders and files
###
[Aa]ssets/AssetStoreTools*
[Bb]uild/
[Ll]ibrary/
[Ll]ocal[Cc]ache/
[Oo]bj/
[Tt]emp/
[Uu]nityGenerated/
# file on crash reports
sysinfo.txt
# Unity3D generated meta files
*.pidb.meta

###
# VS/MD solution and project files
###
[Ee]xportedObj/
*.booproj
*.csproj
*.sln
*.suo
*.svd
*.unityproj
*.user
*.userprefs
*.pidb
.DS_Store

###
# OS generated
###
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db

Note that it does build on my local machine when I try straight from Unity. Thanks in advance for anyone who can help. Keep in mind, I've never used CI before, so this is me also trying to learn. I'm also open to any suggestions for other CI solutions. Something free, preferably something that doesn't need my project to be open source (Private repo), and (preferably) cloud-based.

Upvotes: 0

Views: 303

Answers (1)

Giorgio Taracena
Giorgio Taracena

Reputation: 131

You are missing \ in your build commands. Add it for separate lines, because right now it's not getting the flags. For example:

echo "Attempting to build $project for OS X"
/Applications/Unity/Unity.app/Contents/MacOS/Unity \
  -batchmode \
  -nographics \
  -silent-crashes \
  -logFile $(pwd)/unity.log \
  -projectPath $(pwd) \
  -buildOSXUniversalPlayer "$(pwd)/Build/osx/$project.app" \
  -quit

Upvotes: 1

Related Questions