问题描述
我正在尝试使用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次试验:失败
- 基于ubuntu构建gcloud映像
- 使用该图像运行自定义脚本文件'list-gce.sh'
- 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
rev 2
有什么建议或参考吗?
推荐答案
除了其他答案,要执行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构建步骤文本输出保存到文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!