Reputation: 469
I registered 11 projects of GitLab runner. Runners of each project work fine except 1 project. First time I registered runner of this project, it works. But after I commit/push some changes, an error occurs and failed job. I saw some solutions that upgrading the git version solved a problem, but I don't think so. Because all of the runners work fine except this project.
Server OS: CentOS 7
git: 1.8.3.1
First time registered runner
>Running with gitlab-runner 11.9.2 (...)
on (...)
Using Shell executor...
Running on localhost.localdomain...
Initialized empty Git repository in /home/gitlab-runner/(...)/.git/
Clean repository
Fetching changes with git depth set to 50...
Created fresh repository.
From https://gitlab.com/(...)
* [new branch] master -> origin/master
Checking out (...) as master...
Skipping Git submodules setup
$ echo "> gitlab-ci started"
> gitlab-ci started
$ cd /home/(..)
$ echo "> git pull started"
> git pull started
$ git pull
remote: Total 0 (delta 0), reused 0 (delta 0)
Already up-to-date.
Job succeeded
Second commit/pull, then
>Running with gitlab-runner 11.9.2 (...)
on (...)
Using Shell executor...
Running on localhost.localdomain...
Reinitialized existing Git repository in /home/gitlab-runner/(...)/.git/
Clean repository
Fetching changes with git depth set to 50...
fatal: remote origin already exists.
fatal: git fetch-pack: expected shallow list
ERROR: Job failed: exit status 1
edit. here is my .gitlab-ci.yml
stages:
- deploy
deploy_to_master:
stage: deploy
script:
- echo "> gitlab-ci started"
- cd /home/www/dir
- echo "> git pull started"
- git pull
- echo "> permission set"
- chmod 707 -R ./data/
- chmod 707 -R ./plugin/nice/
- chmod 707 ./favicon.ico
- echo "> server reload(=httpd -k graceful)"
- systemctl reload httpd
only:
- master
tags:
- tags
Upvotes: 36
Views: 62855
Reputation: 2007
Add GIT_STRATEGY=clone
to "config.toml".
/etc/gitlab-runner/config.toml:
...
[[runners]]
...
environment = ["GIT_STRATEGY=clone"]
Upvotes: 0
Reputation: 21
This worked for me.
3.1. In the Gitlab web gui,
3.2. go to your project,
3.3. then: "Settings -> CI / CD -> General pipelines".
3.4. Change the options for:
"Git shallow clone" to: 0
Upvotes: 2
Reputation: 1
rm -fr /home/gitlab-runner/(...) , clean then exists repository
Upvotes: -3
Reputation: 3742
I had a similar issue, and I had to update Git. Centos 7 comes with git-1.8.x which has limitations around gitlab-ci.
Upgrade your git, based on this guide.
Upvotes: 2
Reputation: 952
Centos 7 ships with git version 1.8.3.1 . This version doesn't support commands like git fetch-pack . To fix this problem, you could update git on your server from the IUS repository. update git on Centos 7 to version 2 from third-party IUS repo
$ git --version
git version 1.8.3.1
sudo yum -y install https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo.x86_64.rpm
sudo yum install git
Upvotes: 54
Reputation: 106
Check value in your project's CI/CD settings on gitlab.com. If there is any value in 'git shallow clone' remove it and save changes. Now your pipeline will work as expected.
Upvotes: 5
Reputation: 853
There are a few options to fix this. The problem is the version of git on your runner is too old. And sometimes you can't update git on the runner.
Options to fix:
Upgrade to a newer version of git on the runner.
In .gitlab-ci.yml, use the option to git clone:
variables:
GIT_STRATEGY: clone
Configure Gitlab, change Git strategy for pipelines of the project to "git clone".
3.1. In the Gitlab web gui,
3.2. go to your project,
3.3. then: "Settings -> CI / CD -> General pipelines".
3.4. Change the options for:
Upvotes: 75
Reputation: 4024
You can go around this problem without upgrading git at all:
Set in .gitlab-ci.yml
:
variables:
GIT_STRATEGY: clone
Now every change you make will trigger re-cloning the project, avoiding the need of the problematic git fetch-pack
command.
Remove manually the build directory from gitlab-runner server, so it will have to clone it again.
For project testgroup/testproject
, run:
careful with rm commands!
rm -rf /home/gitlab-runner/builds/UwnzuxxL/0/testgroup/testproject
Notice that after builds
directory you have a random string that will be different from this example.
Upvotes: 7
Reputation: 469
I made a new project and, finally, it works fine. I don't know why the other one didn't work. If the same problems occurs like mine, don't get too serious: Just make a new gitlab project. It is good for your mental well-being.
Upvotes: -1