Last active
May 25, 2022 13:56
-
-
Save mjackson/5887963e7d8b8fb0615416c510ae8857 to your computer and use it in GitHub Desktop.
Travis CI + google-cloud-sdk + updated kubectl + Docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The Google Cloud SDK on Travis is pretty old (2014). So if | |
# you want to use an up-to-date version, you have to install | |
# your own. This config is the bare minimum you'll need to | |
# get an updated version of the SDK + kubectl. | |
cache: | |
directories: | |
# We cache the SDK so we don't have to download it again on subsequent builds. | |
- $HOME/google-cloud-sdk | |
services: | |
# Include the docker service so you can roll your own images. | |
# You can remove this if you already have images somewhere else. | |
- docker | |
env: | |
global: | |
# Do not prompt for user input when using any SDK methods. | |
- CLOUDSDK_CORE_DISABLE_PROMPTS=1 | |
before_install: | |
- if [ ! -d $HOME/google-cloud-sdk/bin ]; then | |
# The install script errors if this directory already exists, | |
# but Travis already creates it when we mark it as cached. | |
rm -rf $HOME/google-cloud-sdk; | |
# The install script is overly verbose, which sometimes causes | |
# problems on Travis, so ignore stdout. | |
curl https://sdk.cloud.google.com | bash > /dev/null; | |
fi | |
# This line is critical. We setup the SDK to take precedence in our | |
# environment over the old SDK that is already on the machine. | |
- source $HOME/google-cloud-sdk/path.bash.inc | |
- gcloud components update kubectl | |
- gcloud version | |
# Insert your own install + script below. | |
install: true | |
script: true |
@OkThought Thanks for your comment. Here is how I reformatted the if block to work with travis:
- if [ ! -d "$HOME/google-cloud-sdk/bin" ]; then rm -rf "$HOME/google-cloud-sdk"; curl https://sdk.cloud.google.com | bash > /dev/null; fi
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanx, some of the solutions here helped me out :)
And by the way this travis config fails to parse due to comments included inside
if
statement