【问题标题】:How do you view a log created during gitlab-runner exec?您如何查看在 gitlab-runner exec 期间创建的日志?
【发布时间】:2018-09-23 19:43:32
【问题描述】:

我正在使用 gitlab-runner exec 测试 GitLab CI 管道。在执行脚本期间,Boost 遇到了一个错误,它创建了一个日志文件。我想查看此日志文件,但不知道如何查看。

.gitlab-ci.yml在项目目录中:

image: alpine

variables:
  GIT_SUBMODULE_STRATEGY: recursive

build:
  script:
  - apk add cmake
  - cd include/boost
  - sh bootstrap.sh

我在我的机器上测试了这个:

sudo gitlab-runner exec docker build --timeout 3600

输出的最后几行:

Building Boost.Build engine with toolset ... 
Failed to build Boost.Build build engine
Consult 'bootstrap.log' for more details
ERROR: Job failed: exit code 1
FATAL: exit code 1    

bootstrap.log 是我想查看的内容。

- cat bootstrap.log 附加到.gitlab-ci.yml 不会输出文件内容,因为运行程序在此行之前退出。我尝试使用 sudo docker ps -a 查看过去的容器,但这并没有显示 GitLab Runner 使用的容器。如何打开bootstrap.log

【问题讨论】:

  • 目前,我只是在我在 GitLab Runner 之外创建的 Docker 容器上测试了这些命令。

标签: docker gitlab gitlab-ci-runner


【解决方案1】:

您可以为日志声明一个工件:

image: alpine

variables:
  GIT_SUBMODULE_STRATEGY: recursive

build:
  script:
    - apk add cmake
    - cd include/boost
    - sh bootstrap.sh

  artifacts:
    when: on_failure
    paths:
      - include/boost/bootstrap.log

之后,您就可以通过网页界面下载日志文件了。

请注意,使用when: on_failure 将确保仅在构建失败时才收集bootstrap.log,从而在成功构建时节省磁盘空间。

【讨论】:

    猜你喜欢
    • 2014-04-05
    • 1970-01-01
    • 2015-06-26
    • 2019-07-16
    • 2021-11-06
    • 2016-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多