1

I have an issue with my CI pipeline on GitLab, stage deploy on server Cloudways. The CI deploy correctly in prod... but it failed with error:

error: could not lock config file /home/123456.cloudwaysapps.com/xxxxxxx/.gitconfig: Permission denied

I read it's a problem with .gitconfig.lock, but I don't see any file "gitconfig.lock" or .git config at this path.

What do you think about this, please? What is the error?

deploy:

stage: deploy
  
before_script:
    - apt-get update -y && apt-get install -y git openssh-client
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh

script:
    - ssh -o StrictHostKeyChecking=no $APP_USER@$APP_HOST "cd public_html/ && git config --global user.name "my-user-name" && git pull origin main && composer dump-autoload && php bin/console d:m:m -n"

only:
    - main

The screen here:

error

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
  • If all you need to do is to pull the changes, then you shouldn't need to set the git config parts of the job. If it's something which needs to be done, then you may be better off logging in to the server and running the config just once, rather than having CI set the same config each time. As such, what happens if you remove the `git config` part of the job, does it work? – gabe3886 Dec 07 '21 at 13:30

1 Answers1

1

As commented, the git config is not needed for a pull.

But still, to investigate more, replace it with a ls -alrth $HOME && id -a, in order to:

  • check there is a ~/.gitconfig
  • see if you need to change its chmod to make it writable
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Hi @VonC, just a tiny question: on my Debian, `man id` tells me `-a → ignore, for compatibility with other versions`; would you know other contexts/OSes where the `-a` option makes something? (probably a kind of "all" I guess :) – ErikMD Dec 11 '21 at 23:07
  • @ErikMD Yes, it is for `-all`. In your case, `id` would suffice. – VonC Dec 11 '21 at 23:48