Cloning on GitHub Enterprise running in private mode fails

Hi,

I have a GitHub Enterprise running in private mode (ie. requires log in before accessing the repositories). I managed to get the Drone authenticate and I can see the list of repos that I have rights to. I can enable those repos for Drone. However, cloning fails:

+ git init
Initialized empty Git repository in /drone/src/github.mine/Wiechec/repo/.git/
+ git remote add origin http://github.mine/Wiechec/repo.git
+ git fetch --no-tags origin +refs/heads/adding-support-for-Drone-CI:
fatal: could not read Username for 'http://github.mine': No such device or address
exit status 128

It looks like it can resolve the github host but fails to provide credentials.

I am starting drone-server with those environment vars:

  • DRONE_GITHUB=true
  • DRONE_GITHUB_URL=http://github.mine
  • DRONE_GITHUB_CLIENT=<redacted>
  • DRONE_GITHUB_SECRET=<redacted>
  • DRONE_GITHUB_PRIVATE_MODE=true
  • DRONE_GITHUB_SKIP_VERIFY=true

What am I doing wrong?

Here is the list of known reasons for this error:

  1. If your repository is public (any GitHub user can view) but GitHub is running in private mode. In this case you need to set GITHUB_PRIVATE_MODE per the installation instructions. When you activate the repository in Drone it will be treated as private, and credentials will be used to clone.
  2. If you added the repository to Drone and the repository was public, but then it was changed in GitHub to private. Drone will continue to think it is public and will not attempt to authenticate with credentials when cloning.
  3. If you are attempting to connect to GitHub using an IP address or custom hostname that is not accessible from inside a Docker container. This typically happens when someone tries to use a custom Docker hostname or localhost or loopback network address to access GitHub from inside the Drone container.
  4. If you activate the repository with a user account, and then either delete that user account or revoke Drone’s access to that user account. This would cause problems because Drone will use this user’s oauth token in the netrc file to authenticate the git clone.

Also note that private mode needs to be set before first use. If this was not the case you are better off deleting the install (including the database) and then restarting the server from scratch. Otherwise you can use the repair command, as described here:
http://docs.drone.io/error-could-not-read-username-for/

big thanks - it worked; as I have forgot to set the private mode I only had to ‘repair’ the repo.

Drone rocks!

awesome, glad to hear that fixed it. You might consider running the below database command to batch update all of your repositories. That way you don’t have to run the repair command on every single repository :slight_smile:

for mysql or postgres:

update repos set repo_private=true where repo_private=false;

for sqlite:

update repos set repo_private=1 where repo_private=0;

thanks for the tip.

I am using SQLite but when I try to open to drone.sqlite file (using sqlite drone.sqlite) the SQLite complains that ‘file is encrypted or is not a database’. How can I open this file?

there is a sqlite3 command line utility that you need to install. You can then do this:

$ sqlite3 path/to/drone.sqlite
> update repos set repo_private=1 where repo_private=0;
> .exit

edit: sorry just read that you were using the sqlite3 command line utility already. I am not familiar with that particular error message.

1 Like