Search code examples
gitdrone.iogogs

"fatal: could not read Username for 'https://XXX': No such device or address" with drone.io and Gogs


I want to use drone.io and gogs in order to have some CI features in my environment.

The documentation of drone.io (http://docs.drone.io/) is not up-to-date, and I had to dig a lot in order to launch it.

My docker-compose.yml file is the following:

version: '3'

services:

  drone-server:
    image: drone/drone:latest
    network_mode: "bridge"
    volumes:
      - "/docker/drone:/var/lib/drone/"
    environment:
      - "DRONE_OPEN=true"
      - "DRONE_HOST=XXX"
      - "DRONE_SECRET=XXX"
      - "DRONE_GOGS=true"
      - "DRONE_GOGS_URL=http://gogs:3000"
      - "DRONE_GOGS_GIT_USERNAME=XXX"
      - "DRONE_GOGS_GIT_PASSWORD=XXX"
      - "DRONE_GOGS_PRIVATE_MODE=true"
    external_links:
      - "dedigogs_gogs_1:gogs"

  drone-agent:
    image: drone/agent:latest
    network_mode: "bridge"
    depends_on:
      - drone-server
    links:
      - drone-server
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
    environment:
      - "DRONE_SERVER=drone-server:9000"
      - "DRONE_HOST=XXX"
      - "DRONE_SECRET=XXX"
      - "DRONE_GOGS=true"
      - "DRONE_GOGS_URL=http://gogs:3000"
      - "DRONE_GOGS_GIT_USERNAME=XXX"
      - "DRONE_GOGS_GIT_PASSWORD=XXX"
      - "DRONE_GOGS_PRIVATE_MODE=true"
    external_links:
      - "dedigogs_gogs_1:gogs"

(dedigogs_gogs_1 being my gogs docker instance)

I can connect to drone using my gogs credentials.

I can see all my private repositories, and enable them for drone.io.

However, when building a commit, the agent (I think) cannot clone the repository:

+ git init
Initialized empty Git repository in /drone/src/XXX/XXX/XXX/.git/
+ git remote add origin https://XXX/XXX/XXX.git
+ git fetch --no-tags origin +refs/heads/master:
fatal: could not read Username for 'https://XXX': No such device or address
exit status 128

I tried playing with the .drone.yml (adding "clone" section, with username, netrc.username, ...), I also tried playing with environment variable, nothings work, I can't make drone authenticate for cloning repository.

Any idea ?


Solution

  • Here is the thing, I've had similar issues with gogs, for some reason the .netrc file is not matching with the url that uses to clone.

    Try instead use the full url you use to access Gogs in the browser instead of the internal hostname in the docker network

    DRONE_GOGS_URL=http://myurl.to.gogs.com:3000
    DRONE_GOGS_URL=http://some-ip-address:3000