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.
How to change this limit?
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
According to the documentation
output_limit : Maximum build log size in kilobytes. Default is 4096 (4MB).
For this to take effect, you need to restart the gitlab runner:
sudo gitlab-runner restart
So an answer for those that don't have access to the gitlab-runners configuration file that #Ortomala Lokni refers too.
You can redirect the logger output and archive it quite easily by doing the following (Note: this is done for maven builds).
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"
Notice within the maven command I am using the --log-file to redirect the maven output to target/client-quality_check.log and then under artifacts I have set to archive this log file by providing the path to the file.
Once this Job finishes I can then look at the Jobs archives and can see my log file with all the logger output in it.
Starting from gitlab 14.1 there is another configuration option that effects maximum log size: ci_jobs_trace_size_limit (100MB by default). So altering only runner limit, as described in other answers, is not sufficient anymore.
Since gitlab is all about speed and usability, modifying ci_jobs_trace_size_limit is possible only by executing command directly in rails console of the system (or docker container) where gitlab is running.
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
Note: if it seems like gitlab-rails console -e production doesn't do anything and console prompt doesn't pop up you'll need to wait.
Related
Hi people of the internet.
Basically I am unable to run even the simplest job and I keep getting the same error no matter what I put in the .gitlab-ci.yml file. See example below:
Here is the .gitlab-ci.yml file:
stages:
- test
job1:
stage: test
tags:
- testing
script:
- echo "Hello world!"
Here is the output ("?" corresponds to intentionally blacked out information):
Running with gitlab-runner 14.10.0 (c6bb62f6)
on runner_test ????????
Preparing the "shell" executor
00:00
Using Shell executor...
Preparing environment
00:00
Running on LAPTOP-????????...
Getting source from Git repository
00:01
WriteError:
Line |
219 | $HOST="[MASKED]"
| ~~~~~~~~~~~~~~~~~~~~~~
| Cannot overwrite variable Host because it is read-only or constant.
ERROR: Job failed: exit status 1
I know that $HOST is a reserved variable in powershell but I don't see the link between the error and the code. It may have something to do with the configuration of the runner on Windows. Has anyone encountered this error on Gitlab before? Or any suggestions on how to debug?
Here are the steps that I took to install the runner on Gitlab for Windows (see https://docs.gitlab.com/runner/install/windows.html):
Create a folder somewhere in the system: C:\GitLab-Runner.
Download the binary for 64-bit and put it into the folder (see https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-windows-amd64.exe).
Run prompt as an administrator
Run the following command:
cd C:\GitLab-Runner
gitlab-runner.exe register
Enter your GitLab instance URL (see Gitlab > Settings > CI/CD > Runners > Specific runners)
Enter the token to register the runner (see Gitlab > Settings > CI/CD > Runners > Specific runners)
Enter a description for the runner: runner_test for instance
Enter the tags associated with the runner, separated by commas: testing, windows for instance
Provide the runner executor: shell
Install GitLab Runner as a service and start it
cd C:\GitLab-Runner
gitlab-runner.exe install
gitlab-runner.exe start
I also had to install the latest version of pwsh in Windows (see gitlab-runner: prepare environment failed to start process pwsh in windows):
Run prompt as an administrator
Install the newer pwsh.exe:
winget install Microsoft.PowerShell
Restart the runner
cd C:\GitLab-Runner
gitlab-runner.exe restart
This issue was due to my choice of shell for some reason. A Gitlab runner can choose a shell among the following: bash, sh, powershell, pwsh, and cmd (the last one being deprecated now).
As I stated above I had been using pwsh. So, I went after the config.toml file inside of the C:\GitLab-Runner directory to manually make the change from pwsh to powershell.
...
[[runners]]
name = "runner_test"
executor = "shell"
shell = "powershell"
...
I then restarted the runner and got the job to complete properly:
cd C:\GitLab-Runner
gitlab-runner restart
I still get the error (more like a warning now) but it does not prevent the job from finishing anymore. If anyone has a better answer with a proper explanation I would gladly accept it as the answer to this question.
Note that pwsh to powershell are both powershell scripts (see https://docs.gitlab.com/runner/shells/index.html):
powershell Fully Supported PowerShell script. All commands are executed in PowerShell Desktop context. In GitLab Runner 12.0-13.12, this is the default when registering a new runner.
pwsh Fully Supported PowerShell script. All commands are executed in PowerShell Core context. In GitLab Runner 14.0 and later, this is the default when registering a new runner.
I've been working on getting a .gitlab-ci.yml pipeline to work but cannot find where the logs go.
GitLab.com message tells me
npm ERR! /root/.npm/_logs/2022-05-06T09_39_43_597Z-debug.log
I do not see this folder created on my project within GitLab.com so where and how do I get to the log?
After 51 iterations I have made a little bit of progress. 1st time seeing Green.
You could use artifacts to keep the log file, if the job fails. For example:
my job:
...
artifacts:
paths:
- "*.log"
when: on_failure
I'm not sure the paths pattern is correct. So, perhaps, it is neccessary to use **/*.log instead of *.log. But I hope, the idea is clear.
That can be seen by adding debug logging to your .gitlab-ci.yml file.Once you add it ,run the job again and you can get a detailed log
I have one gitlab runner configured for a single project. The issue that I am seeing is that the runner will not wait until the prior job finished, and instead does a checkout in the same directory as the prior job and stomps over everything. I have one job already running, and then another develop commits and thus another job is started. Why can't I configure the pipeline not to run so that it doesn't corrupt the already running workspace?
Here is the log from both of the jobs (only difference is the timestamp)
[0K] Running with gitlab-runner 12.6.0 (ac8e767a)
[0K] on gitlab.xxxx.com rz8RmGp4
[0K] section_start:1578357551:prepare_executor
[0K] Using Docker executor with image my-image-build ...
[0K] Using locally found image version due to if-not-present pull policy
[0K] Using docker image sha256:xxxxxxxxxx for my-image-build ...
[0;msection_end:1578357553:prepare_executor
[0Ksection_start:1578357553:prepare_script
[0K] Running on runner-rz8RmGp4-project-23-concurrent-0 via gitlab.xxxx.com...
section_end:1578357554:prepare_script
[0K] section_start:1578357554:get_sources
[0K[32;1mFetching changes with git depth set to 50...[0;m
Initialized empty Git repository in /builds/my-project/.git/
<proceeds to checkout and stomp over the already running runner>
Main issue I see is that they both checkout to the same directory of Initialized empty Git repository in /builds/my-project/.git/ which causes the problem.
You can use resource_group to keep jobs from running in parallel.
e.g.
Job 1:
stage: My Stage
resource_group: stage-wedge
...
Job 2:
stage: My Stage
resource_group: stage-wedge
...
In the above example Job 2 will run after Job 1 is finished.
Jobs of same stage are executed in parallel.
if you need it to be sequential, you may add a stage for each of those jobs.
see the docs
https://docs.gitlab.com/ee/ci/yaml/#stages
In case of multiple pipelines running you may want to configure your gitlab-runner options: limit / concurrent
https://docs.gitlab.com/runner/configuration/advanced-configuration.html
I install a Specific Runners,and the status is actived.
my .gitlab-ci.ymi file code:
stages:
- build
build_maven:
stage: build
only:
- master
script:
- echo "hello CI/CD"
tags:
- vue-dev-pub
when I push the master branch,the gitlab-runner is running,but it's pending infinitely。
the job page show:
This job has not started yet
This job is in pending state and is waiting to be picked by a runner
if I excute the runner manually,the job can pass.
the command of gitlab-runner verify shows:
Runtime platform arch=amd64 os=linux pid=24616 revision=d0b76032 version=12.0.2
WARNING: Running in user-mode.
WARNING: The user-mode requires you to manually start builds processing:
WARNING: $ gitlab-runner run
WARNING: Use sudo for system-mode:
WARNING: $ sudo gitlab-runner...
Verifying runner... is alive runner=T4iKvsT3
I am waiting for you respond,thanks!
If you run the runner manually in debug mode gitlab-runner --debug run you may see the actual error message, in my case it was:
WARNING: Failed to process runner builds=0 error=failed to update executor: missing Machine options executor=docker+machine runner=pSUsX4yR
That's because on runner creation, I selected option docker+machine rather than docker.
After amending /etc/gitlab-runner/config.toml to docker and running gitlab-runner restart followed by gitlab-runner verify, pipeline started running again.
I had a similar problem with my (shell) runners on linux. It would work fine on runners installed and registered on one of my computers but not another. (Even as tags matched correctly in runner and job)
After
gitlab-runner register I would get:
New runner. Has not connected yet
After
gitlab-runner verify that error would go away. But I would get This job is in pending state and is waiting to be picked by a runner
After
gitlab-runner restart
It would all work.
gitlab-runner status
gitlab-runner: Service is running!
Maybe you have tagged your runner but your job has no tags. Refer :how to run untagged jobs
https://stackoverflow.com/a/53371027/10570524
The tags section in your .gitlab-ci.yml file specifies this job has to be picked by a runner that has the same tags (reference).
tags:
- vue-dev-pub
So unless there is actually a runner available for your project that has the vue-dev-pub tag it will keep waiting for one to become available.
first, remove the old config in sys
rm /etc/systemd/system/gitlab-runner.servicetemd
now, you need install gitlab-runner with gitlab user:
gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner
root installations fail
I've failed on running job by gitlab-runner using shell-executor.My setup is one server(centos6), with Gitlab installed, and the same server has the runners installed and configured.
Gitlab v11.8.0-ee
My project has a very simple yaml config file:
dev:
script:
- pwd
when running a job,I get the following output:
[0KRunning with gitlab-runner 11.8.0 (4745a6f3)
[0;m[0K on holiday zs7axHmm
[0;m[0KUsing Shell executor...
[0;msection_start:1551421397:prepare_script
[0KRunning on host-192-168-200-85...
section_end:1551421397:prepare_script
[0Ksection_start:1551421397:get_sources
[0K[32;1mFetching changes...[0;m
HEAD is now at ba9b6da Add new file
[32;1mChecking out ba9b6dac as master...[0;m
[32;1mSkipping Git submodules setup[0;m
section_end:1551421398:get_sources
[0Ksection_start:1551421398:restore_cache
[0Ksection_end:1551421398:restore_cache
[0Ksection_start:1551421398:download_artifacts
[0Ksection_end:1551421398:download_artifacts
[0Ksection_start:1551421398:build_script
[0K[32;1m$ # Auto DevOps variables and functions # collapsed multi-line command[0;m
[32;1m$ setup_docker[0;m
[32;1m$ build[0;m
Logging to GitLab Container Registry with CI credentials...
bash: line 91: docker: command not found
section_end:1551421398:build_script
[0Ksection_start:1551421398:after_script
[0Ksection_end:1551421398:after_script
[0Ksection_start:1551421398:upload_artifacts_on_failure
[0Ksection_end:1551421398:upload_artifacts_on_failure
[0K[31;1mERROR: Job failed: exit status 1
[0;m`
I disabled shared runner for this project.but still job fails with docker error.
because project has gitlab-ci.yml instead of .gitlab-ci.yml ,gitlab-runner skip my config file and use default config that run docker command while I set executor to shell.the file name is very important and because my file name dosen't start with "." ,gitlab-runner ignore my config.