How to install Google Cloud SDK on Travis?

南楼画角 提交于 2019-12-03 13:33:17

You are running into this issue because there is no interaction possible on Travis CI. Hence, the installation script is blocked waiting for input and Travis CI kills the build after 10 minutes.

The trick is to disable the prompts when installing the Google Cloud SDK. This can be done by setting the CLOUDSDK_CORE_DISABLE_PROMPTS environment variable to 1.

Here's a sample recipe to put in your .travis.yml file (including caching it for faster subsequent builds):

cache:
  directories:
    - "$HOME/google-cloud-sdk/"
script:
  - gcloud version || true
  - if [ ! -d "$HOME/google-cloud-sdk/bin" ]; then rm -rf $HOME/google-cloud-sdk; export CLOUDSDK_CORE_DISABLE_PROMPTS=1; curl https://sdk.cloud.google.com | bash; fi
  # Add gcloud to $PATH
  - source /home/travis/google-cloud-sdk/path.bash.inc
  - gcloud version

Hope this helps!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!