你如何查看在 gitlab-runner exec 期间创建的日志?

Mak*_*toE 4 gitlab docker gitlab-ci-runner

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

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

image: alpine

variables:
  GIT_SUBMODULE_STRATEGY: recursive

build:
  script:
  - apk add cmake
  - cd include/boost
  - sh bootstrap.sh
Run Code Online (Sandbox Code Playgroud)

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

sudo gitlab-runner exec docker build --timeout 3600
Run Code Online (Sandbox Code Playgroud)

输出的最后几行:

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    
Run Code Online (Sandbox Code Playgroud)

bootstrap.log 是我想看的。

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

Phi*_*wig 7

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

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
Run Code Online (Sandbox Code Playgroud)

之后,您将能够通过 Web 界面下载日志文件。

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