首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何访问GCP云构建步骤创建的日志文件?

如何访问GCP云构建步骤创建的日志文件?
EN

Stack Overflow用户
提问于 2020-11-09 08:28:18
回答 1查看 147关注 0票数 0

我的云构建在npm test上超时失败,没有任何有用的信息被发送到stdout。可以在文件中找到完整的日志,但我无法找到在云构建环境中使用ssh的方法。

代码语言:javascript
复制
Already have image: node

> project-client@v3.0.14 test
> jest

ts-jest[versions] (WARN) Version 4.1.0-beta of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=3.8.0 <5.0.0-0). Please do not report issues in ts-jest if you are using unsupported versions.
npm ERR! path /workspace/v3/client
npm ERR! command failed
npm ERR! signal SIGTERM
npm ERR! command sh -c jest

npm ERR! A complete log of this run can be found in:
npm ERR!     /builder/home/.npm/_logs/2020-11-09T07_56_23_573Z-debug.log

由于我在本地运行测试没有问题,所以我希望看到这个2020-11-09T07_56_23_573Z-debug.log文件的内容,希望能得到可能出错的提示。

有检索文件内容的方法吗?

云构建environment?

  • Get npm中的
  • Ssh将完整的日志打印到stdout?
  • 中,以某种方式将日志文件工件保存到云存储中?
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-11-09 13:57:59

我在Gitlab CI上有一个类似的错误管理问题,我的解决方法也是从那里得到灵感的。

诀窍是将命令嵌入到使用返回代码0退出的东西中。这里有一个例子

代码语言:javascript
复制
 - name: node
   entrypoint: "bash"
   args:
     - "-c"
     - |
          RETURN_CODE=$$(jtest > log.stdout 2>log.stderr;echo $${?})
          cat log.stdout
          cat log.stderr
          if [ $${RETURN_CODE} -gt 0 ]; 
          then 
            #Do what you want in case of error, like a cat of the files in the _logs dir
            # Break the build: exit 1
          else 
            #Do what you want in case of success. Nothing to continue to the next step
          fi

一些解释:

interpreted.

  • The

  • 回显$${?}:double $是用来指示Cloud不要使用替代变量,而是要忽略它,让Linux命令成为

  • $?允许您获取前面命令

  • 的退出代码,然后测试退出代码,如果> 0,则可以执行操作。最后,我建议不要继续使用错误的源代码来破坏构建。

  • 您可以解析log.stderr文件以获得有用的信息(例如日志文件)

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64748096

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档