如何将Google Cloud构建步骤文本输出保存到文件 [英] How can I save google cloud build step text output to file

查看:81
本文介绍了如何将Google Cloud构建步骤文本输出保存到文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Google Cloud build.第一步,我需要获取所有正在运行的计算实例的列表.

I'm trying to use google cloud build. At one step, I need to get a list of all running compute instances.

- name: gcr.io/cloud-builders/gcloud
  args: ['compute', 'instances', 'list']

,它工作正常.当我尝试将输出保存到文件时,问题开始了

and it works fine. Problem starts when I tried to save the output to a file

试验1 :失败

- name: gcr.io/cloud-builders/gcloud
  args: ['compute', 'instances', 'list', '> gce-list.txt']


试验2 :失败


Trial 2: failed

- name: gcr.io/cloud-builders/gcloud
  args: ['compute', 'instances', 'list', '>', 'gce-list.txt']


试验3 :失败


Trial 3: failed

- name: gcr.io/cloud-builders/gcloud
  args: >
      compute instances list > gce-list.txt


试验4 :失败


Trial 4: failed

- name: gcr.io/cloud-builders/gcloud
  args: |
      compute instances list > gce-list.txt


更新时间:2018-09-04 17:50

第5次试验:失败

  1. 基于ubuntu构建gcloud映像
  2. 使用该图像运行自定义脚本文件'list-gce.sh'
  3. list-gce.sh调用gcloud compute instances list

有关更多详细信息,您可以检查以下要点: https://gist.github.com/mahmoud-samy/e67f141e8b5d553de68a58a30a432ed2

For more details you can check this gist: https://gist.github.com/mahmoud-samy/e67f141e8b5d553de68a58a30a432ed2

不幸的是,我遇到了这个奇怪的错误:

Unfortunately I got this strange error:

rev 1

错误:(gcloud)无法识别的参数:列表(您是说列表"吗?)

ERROR: (gcloud) unrecognized arguments: list (did you mean 'list'?)

rev 2

错误:(gcloud)无法识别的参数:--version(您是说'--version'吗?)

ERROR: (gcloud) unrecognized arguments: --version (did you mean '--version'?)

有什么建议或参考吗?

推荐答案

除了其他答案,要执行cmd > foo.txt,您还需要将构建入口点覆盖为bash(或sh):

In addition to other answers, to do cmd > foo.txt, you need to override the build entrypoint to bash (or sh):

- name: gcr.io/cloud-builders/gcloud
  entrypoint: /bin/bash
  args: ['-c', 'gcloud compute instances list > gce-list.txt']

这篇关于如何将Google Cloud构建步骤文本输出保存到文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆