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

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

问题描述

我正在尝试使用谷歌云构建.在一个步骤中,我需要获取所有正在运行的计算实例的列表.

- 名称:gcr.io/cloud-builders/gcloud参数:['计算','实例','列表']

而且它工作正常.当我尝试将输出保存到文件时出现问题

<小时>

试验 1:失败

- 名称:gcr.io/cloud-builders/gcloud参数:['计算','实例','列表','>gce-list.txt']

<小时>

试验 2:失败

- 名称:gcr.io/cloud-builders/gcloud参数:['计算','实例','列表','>','gce-list.txt']

<小时>

试验 3:失败

- 名称:gcr.io/cloud-builders/gcloud参数:>计算实例列表 >gce-list.txt

<小时>

试验 4:失败

- 名称:gcr.io/cloud-builders/gcloud参数: |计算实例列表 >gce-list.txt

<小时>

更新:2018-09-04 17:50

试验 5:失败

  1. 基于 ubuntu 构建 gcloud 镜像
  2. 使用该图像运行自定义脚本文件list-gce.sh"
  3. list-gce.sh 调用 gcloud 计算实例列表

有关更多详细信息,您可以查看此要点:https://gist.github.com/mahmoud-samy/e67f141e8b5d553de62a5>

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

版本 1

<块引用>

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

版本 2

<块引用>

错误:(gcloud) 无法识别的参数:--version(您的意思是--version"吗?)

有什么建议或参考吗?

解决方案

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

- 名称:gcr.io/cloud-builders/gcloud入口点:/bin/bashargs: ['-c', 'gcloud 计算实例列表 >gce-list.txt']

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


Trial 1: failed

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


Trial 2: failed

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


Trial 3: failed

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


Trial 4: failed

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


UPDATE: 2018-09-04 17:50

Trial 5: failed

  1. Build an gcloud image based on ubuntu
  2. Used that image to run custom script file 'list-gce.sh'
  3. list-gce.sh calls gcloud compute instances list

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

Unfortunately I got this strange error:

rev 1

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

rev 2

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

Any suggestions, or references?

解决方案

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']

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

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