Gitlab vs Redmine

Main problem when synchronizing Gitlab and Redmine is user authentication. The webhook does not work (as it is executed as www-data).

Let’s say we have a mirror clone here:

cd /opt/repos/propmat.git

We need to set a crontab task like this:

*/2 * * * * cd /opt/repos/myrepo.git && git fetch -q --all -p

But we need to enter as www-data in order to execute crontab -e to add the task:

su -s /bin/bash www-data

The home directory for www-data is /var/www. As we need to create git credentials for the user, we must set www-data as the owner of that directory (in a temporary way)

Then, we will be able to configure the credentials (from the shell of www-data):

git config --global credential.helper store

Once this is done, we can do this for first time:

cd /opt/repos/myrepo.git && git fetch -q --all -p

and then the credentials are saved.

If you look at the .git-credentials file, the password is plain, so it is interesting to create (in gitlab) a project member for redmine, in reporter mode (so it can access but not modify contents), and use this user and password to access to it.