Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install Google Cloud SDK on Travis?

I have tried to install Google Cloud SDK on Travis with the following .travis.yml

sudo: required

language: go

- curl https://sdk.cloud.google.com | bash;

My attempt is inspired by this guide from Google: https://cloud.google.com/solutions/continuous-delivery-with-travis-ci

Unfortunately, I get this output on Travis:

$ curl https://sdk.cloud.google.com | bash;
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   421    0   421    0     0  17820      0 --:--:-- --:--:-- --:--:-- 60142
Downloading Google Cloud SDK install script: https://dl.google.com/dl/cloudsdk/channels/rapid/install_google_cloud_sdk.bash
######################################################################## 100.0%
Running install script from: /tmp/tmp.uz8jP70e56/install_google_cloud_sdk.bash
which curl
curl -# -f https://dl.google.com/dl/cloudsdk/channels/rapid/google-cloud-sdk.tar.gz
######################################################################## 100.0%
Installation directory (this will create a google-cloud-sdk subdirectory) (/home/travis): 

Travis waits for 10 minutes and then terminates the build. It seems like it is waiting for an installation directory.

How do I install Google Cloud SDK on Travis?

like image 224
user1283776 Avatar asked Aug 04 '16 08:08

user1283776


People also ask

Where is Google Cloud SDK installed?

The installer can be downloaded from the Google Cloud Platform website, or from the Windows or MacOS distribution channels. Once the installer is run, the Cloud SDK is installed in the same directory as the installer.

How do I install Google Cloud SDK on Windows 10?

Download the installer from the link provided: https://cloud.google.com/sdk/docs/quickstart-windows. The installer is a GUI-based utility which will install the requisites for the SDK, and the SDK with default configuration.


1 Answers

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!

like image 70
Dominic Jodoin Avatar answered Sep 24 '22 22:09

Dominic Jodoin