Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gitea git fetch always fatal #473

Closed
4 tasks done
cubesky opened this issue Oct 25, 2021 · 8 comments
Closed
4 tasks done

Gitea git fetch always fatal #473

cubesky opened this issue Oct 25, 2021 · 8 comments
Labels
bug Something isn't working plugin

Comments

@cubesky
Copy link

cubesky commented Oct 25, 2021

Component

server, agent, other

Describe the bug

Git fetch always fatal using Gitea OAuth.

This happens on DroneCI too, but add DRONE_GIT_ALWAYS_AUTH=true can solve this problem. It there any similar solution for woodpecker? WOODPECKER_GIT_ALWAYS_AUTH doesn't work.

System Info

{"source":"https://github.com/woodpecker-ci/woodpecker","version":"next-7725058f"}

Additional context

+ git init
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint: 
hint: 	git config --global init.defaultBranch <name>
hint: 
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint: 
hint: 	git branch -m <name>
Initialized empty Git repository in /drone/src/git.example.com/foobar/test-repo/.git/
+ git remote add origin https://example.com/cubesky/test-repo.git
+ git fetch --no-tags origin +refs/heads/master:
fatal: could not read Username for 'https://git.example.com': No such device or address
exit status 128

Gitea URL and username is replaced with example.com and foobar

Woodpecker and Gitea is on the same host with docker.

Validations

@cubesky
Copy link
Author

cubesky commented Oct 25, 2021

woodpecker docker-compose.yml

version: '3'

services:
  woodpecker-server:
    image: woodpeckerci/woodpecker-server:latest
    ports:
      - 192.168.192.2:11491:8000
    volumes:
      - ./data:/var/lib/drone/
    environment:
      - WOODPECKER_OPEN=true
      - WOODPECKER_HOST=https://ci.example.com
      - WOODPECKER_AGENT_SECRET=example_secret
      - WOODPECKER_GITEA=true
      - WOODPECKER_GITEA_URL=https://git.example.com
      - WOODPECKER_GITEA_CLIENT=example_gitea_client
      - WOODPECKER_GITEA_SECRET=example_gitea_secret
      - WOODPECKER_GIT_ALWAYS_AUTH=true
  woodpecker-agent:
    image: woodpeckerci/woodpecker-agent:latest
    command: agent
    restart: always
    depends_on:
      - woodpecker-server
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - WOODPECKER_SERVER=woodpecker-server:9000
      - WOODPECKER_AGENT_SECRET=example_secret

Drone docker-compose.yml

version: "3.6"
services:
  drone:
    image: drone/drone:2
    ports:
      - 192.168.192.2:11380:80
    environment:
      DRONE_GITEA_SERVER: "https://git.example.com"
      DRONE_GITEA_CLIENT_ID: "example_gitea_clientid"
      DRONE_GITEA_CLIENT_SECRET: "example_gitea_secret"
      DRONE_RPC_SECRET: "example_secret"
      DRONE_SERVER_HOST: "ci.example.com"
      DRONE_SERVER_PROTO: "https"
      DRONE_USER_CREATE: "username:foo,admin:true,token:bar"
      DRONE_GIT_ALWAYS_AUTH: "true"
    volumes:
      # attach a directory relative to the directory containing this compose file
      - ./data:/data
    restart: always

Drone Agent docker-compose.yml

version: "3.6"
services:
  drone:
    image: drone/drone-runner-docker:1
    ports:
      - 192.168.192.2:18182:18182
    environment:
      DRONE_HTTP_BIND: "18182"
      DRONE_RUNNER_CAPACITY: "1"
      DRONE_RUNNER_NAME: "Example-Docker"
      DRONE_RPC_SECRET: "example_secret"
      DRONE_RPC_HOST: "ci.example.com"
      DRONE_RPC_PROTO: "https"
    restart: always
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

@6543
Copy link
Member

6543 commented Oct 25, 2021

@cubesky is the repo you like to fetch from private?

@cubesky
Copy link
Author

cubesky commented Oct 25, 2021

@cubesky is the repo you like to fetch from private?

Yes, it is internal repo.

@6543
Copy link
Member

6543 commented Oct 25, 2021

Ok you got hit by: woodpecker-ci/plugin-git#4

TLD: my bad - it is a known issue that still need a fix

The drone "fix" is just a workaround you could "do" via secrets, but i would not recommend to use your own account

@6543
Copy link
Member

6543 commented Oct 25, 2021

So i propose: create an "clone" account with read permissions only and add credentials (user+token) to secrets & pass it to the git plugin

If you have matrix/discord we can chat how to do there too :)

@6543 6543 added the plugin label Oct 25, 2021
@cubesky
Copy link
Author

cubesky commented Oct 26, 2021

I think use user's permission to clone repo is better than using a "clone" user.
I have discord account. My matrix server is broken. (Sad)

@6543
Copy link
Member

6543 commented Oct 29, 2021

-> #479

@LamaAni
Copy link
Contributor

LamaAni commented Feb 8, 2022

#760

6543 pushed a commit that referenced this issue Feb 8, 2022
As a developer using an custom git server (e.g. Github Enterprise) I would like to be able to authenticate 
the user on repositories which are marked as public.

See issue: #473

Ref: #693 (comment)
@qwerty287 qwerty287 added bug Something isn't working and removed pending:bug labels Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working plugin
Projects
None yet
Development

No branches or pull requests

4 participants