如何在Travis上安装Google Cloud SDK? [英] How to install Google Cloud SDK on Travis?
问题描述
我试图在Travis上安装Google Cloud SDK,其中包含以下 .travis.yml
sudo:必需
语言:go
- curl https://sdk.cloud.google.com |庆典;
我的尝试灵感来自Google的这份指南: https://cloud.google.com/solutions/continuous-delivery-with-travis-ci
不幸的是,我在Travis上得到了这个输出结果:
$ curl https:/ /sdk.cloud.google.com |庆典;
%总计%接收%Xferd平均速度时间时间时间当前
上传总花费左速度
100 421 0 421 0 0 17820 0 - : - : - - : - - - : - - : - : - 60142
下载Google Cloud SDK安装脚本:https://dl.google.com/dl/cloudsdk/channels/rapid/install_google_cloud_sdk.bash
# ################################################## ##################### 100.0%
运行安装脚本:/tmp/tmp.uz8jP70e56/install_google_cloud_sdk.bash
curl
curl - #-f https://dl.google.com/dl/cloudsdk/channels/rapid/google-cloud-sdk.tar.gz
############ ################################################## ########## 100.0%
安装目录(这将创建一个google-cloud-sdk子目录)(/ home / travis):
Travis等待10分钟,然后终止构建。它似乎是在等待安装目录。
如何在Travis上安装Google Cloud SDK?
你遇到这个问题是因为在Travis CI上没有可能的交互。因此,安装脚本被阻止等待输入,而Travis CI会在10分钟后终止构建。
诀窍是在安装Google Cloud SDK时禁用提示。这可以通过将 CLOUDSDK_CORE_DISABLE_PROMPTS
环境变量设置为 1
。
下面是一个示例菜谱,放在.travis.yml文件中(包括缓存它以便更快的后续构建):
缓存:
目录:
- $ HOME / google-cloud-sdk /
脚本:
- gcloud版本||真
- if [! -d$ HOME / google-cloud-sdk / bin];然后rm -rf $ HOME / google-cloud-sdk;导出CLOUDSDK_CORE_DISABLE_PROMPTS = 1;卷曲https://sdk.cloud.google.com |庆典; fi
#将gcloud添加到$ PATH
- source /home/travis/google-cloud-sdk/path.bash.inc
- gcloud版本
希望这有助于您!
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?
解决方案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 to1
.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!
这篇关于如何在Travis上安装Google Cloud SDK?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!