Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you view a log created during gitlab-runner exec?

I am testing a GitLab CI pipeline with gitlab-runner exec. During a script, Boost ran into an error, and it created a log file. I want to view this log file, but I do not know how to.

.gitlab-ci.yml in project directory:

image: alpine

variables:
  GIT_SUBMODULE_STRATEGY: recursive

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

I test this on my machine with:

sudo gitlab-runner exec docker build --timeout 3600

The last several lines of the output:

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 is what I would like to view.

Appending - cat bootstrap.log to .gitlab-ci.yml does not output the file contents because the runner exits before this line. I tried looking though past containers with sudo docker ps -a, but this does not show the one that GitLab Runner used. How can I open bootstrap.log?

like image 325
MakotoE Avatar asked Mar 06 '23 09:03

MakotoE


1 Answers

You can declare an artifact for the log:

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

Afterwards, you will be able to download the log file via the web interface.

Note that using when: on_failure will ensure that bootstrap.log will only be collected if the build fails, saving disk space on successful builds.

like image 160
Philipp Ludwig Avatar answered Mar 16 '23 08:03

Philipp Ludwig