Gitlab CI/CD job's log exceeded limit

Ort*_*kni 4 gitlab gitlab-ci gitlab-ci-runner

When I run my job on Gitlab CI/CD, after a while I obtain the following error message:

Job's log exceeded limit of 4194304 bytes.
Run Code Online (Sandbox Code Playgroud)

How to change this limit?

Pop*_*eye 24

因此,对于那些无法访问所引用的gitlab-runners配置文件的人@Ortomala Lokni来说,这是一个答案。

您可以通过执行以下操作来重定向记录器输出并轻松归档它(注意:这是针对 Maven 构建完成的)。

quality-check:
    extends: .retry-on-job-failure
    stage: quality-check
    timeout: 2 hours
    artifacts:
        name: "$CI_BUILD"
        paths:
            - target/client-quality_check.log
        when: always
        expire_in: 3 days
    only:
        - main
        - merge_requests
    script:
        - echo "Sonar Qube Start"
        - mvn MAVEN_CLI_OPTS sonar:sonar --log-file target/client-quality_check.log \-Dsonar.projectKey=$PROJECT_ KEY \-Dsonar.host.url=$SONAR_HOST_URL \-Dsonar.login=$SONAR_TOKEN 
        - echo "Sonar Qube Complete"
Run Code Online (Sandbox Code Playgroud)

请注意,在 Maven 命令中,我使用 将--log-fileMaven 输出重定向到target/client-quality_check.log,然后在下面artifacts设置通过提供文件路径来归档该日志文件。

一旦此作业完成,我就可以查看作业档案,并可以查看我的日志文件,其中包含所有记录器输出。


Ort*_*kni 7

To change the build log size of your jobs in Gitlab CI/CD, you can edit your config.toml file and add a new limit in kilobytes:

[[runners]]
  output_limit = 10000
Run Code Online (Sandbox Code Playgroud)

According to the documentation

output_limit : Set maximum build log size in kilobytes, by default set to 4096 (4MB)

  • 我这样做了,但变化没有反映出来。我仍然收到相同的错误消息 (3认同)
  • 对我来说,这种变化也没有显示出任何效果。我发现gitlab-runner需要重新启动,现在可以工作了。重新启动 gitlb-runner 的命令 --> "sudo gitlab-runner restart" (3认同)

use*_*670 6

从 gitlab 14.1 开始,还有另一个影响最大日志大小的配置选项:(ci_jobs_trace_size_limit默认为 100MB)。因此,如其他答案中所述,仅更改跑步者限制是不够的。

由于 gitlab 注重速度和可用性,因此ci_jobs_trace_size_limit只能通过直接在运行 gitlab 的系统(或 docker 容器)的 Rails 控制台中执行命令来进行修改。

root@192:/# gitlab-rails console -e production
--------------------------------------------------------------------------------
 Ruby:         ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [x86_64-linux]
 GitLab:       14.8.2 (c7be43f6dd3) FOSS
 GitLab Shell: 13.23.2
 PostgreSQL:   12.7
-----------------------------------------------------------[ booted in 122.49s ]
Loading production environment (Rails 6.1.4.6)
irb(main):001:0> Plan.default.actual_limits.update!(ci_jobs_trace_size_limit: 100000000)
=> true
irb(main):002:0> quit

Run Code Online (Sandbox Code Playgroud)

注意:如果看起来gitlab-rails console -e production没有执行任何操作并且控制台提示符没有弹出,您需要等待。