0

I am using git 2.19.0 and I have my release CI job failing.

I want to authenticate using git git-credentials.

This is how I create my $HOME/.config/git/credentials

if [[ "${CI_PROJECT_URL}" =~ (([^/]*/){3}) ]]; then
  mkdir -p $HOME/.config/git
  echo "${BASH_REMATCH[1]/:\/\//://gitlab-ci-token:${GL_TOKEN:-$GITLAB_TOKEN}@}" > $HOME/.config/git/credentials
  git config --global credential.helper store
fi

This is what I have in .git/config:

[fetch]
    recurseSubmodules = false
[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
    url = https://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@git.example.com/some-org/some-project.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master

This is what I have in $HOME/.config/git/credentials:

$ cat $HOME/.config/git/credentials
https://gitlab-ci-token:Dwq456WQd4q56QW@git.example.com/

However, when I do git push, it fails to use that configuration, instead it read the one from .git/config within the project.

Doing cp $HOME/.config/git/credentials ~/.git-credentials did not help.

Why would a $HOME/.config/git/credentials would be ignored when I do git push?

Dimitri Kopriwa
  • 13,139
  • 27
  • 98
  • 204
  • What's the relevant configuration in `.git/config` that you think might be overriding this? – bk2204 Oct 02 '18 at 01:42
  • In Gitlab-CI, the git strategy is a git fetch, the url used within `.git/config` is a https url including a read only project token. I have tried to `git set remote-url origin https://myproject.git` so it remove the credential here but that doesn't make the git credential store used either. – Dimitri Kopriwa Oct 02 '18 at 14:12

0 Answers0