woodpecker-ci / woodpecker

Woodpecker is a simple, yet powerful CI/CD engine with great extensibility.
https://woodpecker-ci.org
Apache License 2.0
4.07k stars 353 forks source link

Gitea webhooks not working, 404. #572

Closed FarisZR closed 2 years ago

FarisZR commented 2 years ago

Component

server, web-ui

Describe the bug

Hi, I have been trying to use woodpecker with codeberg

But webhooks don't work, they are resulting in 404s woodpecker is behind Nginx proxy manager if that matters.

System Info

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

version: '3.3'
networks:
  default:
  web:
    external: true

services:
  woodpecker-server:
    container_name: woodpecker
    image: woodpeckerci/woodpecker-server:latest
    # ports:
    #   - 127.0.0.1:9002:8000
    volumes:
      - ./woodpecker:/var/lib/woodpecker/
    environment:
      - 'WOODPECKER_ADMIN=FarisZR'
      - 'WOODPECKER_OPEN=true'
      - 'WOODPECKER_HOST=https://cd.xxx.xxx'
      - 'WOODPECKER_GITEA=true'
      - 'WOODPECKER_GITEA_URL=https://codeberg.org'
      - 'WOODPECKER_GITEA_CLIENT=xxxxx'
      - 'WOODPECKER_GITEA_SECRET=xxxxxxxx'
      - 'WOODPECKER_AGENT_SECRET=xxxxxxxxxxx'
    networks:
      - web
      - default

  woodpecker-agent:
    image: woodpeckerci/woodpecker-agent:latest
    command: agent
    restart: always
    depends_on:
      - woodpecker-server
    volumes:
      - /run/user/1001/docker.sock:/var/run/docker.sock
    environment:
      - WOODPECKER_SERVER=woodpecker:9000 
      - 'WOODPECKER_AGENT_SECRET=xxxxxxxxxxx'
      - WOODPECKER_BACKEND=docker
    networks:
      - default

Debian 11 with Docker rootless

Additional context

woodpecker             | {"level":"error","time":"2021-12-07T16:31:23Z","message":"error: XX/REPO: cannot find  in refs/heads/V3-Dev: ConfigFetcher: Fallback did not found config: 404 Not Found"}
woodpecker             | {"level":"error","error":"Error #01: ConfigFetcher: Fallback did not found config: 404 Not Found\n","ip":"172.19.0.3","latency":167.547404,"method":"POST","path":"/hook","status":404,"time":"2021-12-07TXX:XX:XX","user-agent":"Go-http-client/1.1","time":"2021-12-07TXX:XXZ"}

cd-woodpecker-agent-1  | {"level":"error","error":"rpc error: code = Unavailable desc = closing transport due to: connection error: desc = \"error reading from server: EOF\", received prior goaway: code: ENHANCE_YOUR_CALM, debug data: \"too_many_pings\"","time":"2021-12-07T16:54:30Z","message":"grpc error: done(): code: Unavailable: rpc error: code = Unavailable desc = closing transport due to: connection error: desc = \"error reading from server: EOF\", received prior goaway: code: ENHANCE_YOUR_CALM, debug data: \"too_many_pings\""}

Validations

anbraten commented 2 years ago

@fariszr Have you checked your webhook in the codeberg project settings. You should be able to see the error why the webhooks are not reaching woodpecker there.

FarisZR commented 2 years ago

Yes its showing up as 404 in codeberg. Do you want to send you the header ?

-------- Original Message -------- On Dec. 8, 2021, 1:08 a.m., woodpecker-ci/woodpecker - reply+aipxadu6gantl5bitgcmelv7xo6gtevbnhhd77l5eu at reply.github.com wrote:

@.***(https://github.com/fariszr) Have you checked your webhook in the codeberg project settings. You should be able to see the error why the webhooks are not reaching woodpecker there.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

anbraten commented 2 years ago

The url should be something like: https://ci.example.tld/hook?access_token=xxx.

Screenshot from 2021-12-07 23-31-17

FarisZR commented 2 years ago

yes the URL is showing up correctly. however all Deliveries as i mentioned before are ending up in 404 response

anbraten commented 2 years ago

Weird. Could you try curl -d "access_token=justempty" -H "Content-Type: application/x-www-form-urlencoded" -X POST -i https://ci.woodpecker-ci.org/hook It should always return a 200 even if the access token is wrong and the webhook is not handled by woodpecker (security reasons).

Can you access the UI via your reverse-proxy at all? Seems as you got the system-info from https://ci.example.tld/version

FarisZR commented 2 years ago

yes the UI works and i can login and manage my repos, but because the webhook doesn't work, the commits don't show up. i tried it with curl, and it gave a 200 response with the access token and without it. however manually visiting the webhook link from the browser gives a 404.

susnux commented 2 years ago

manually visiting the webhook link from the browser gives a 404.

Thats because the browser issues a GET request, that always results in an 404.

anbraten commented 2 years ago

@fariszr Could you test it without nginx proxy manager. We had a possibliy similar problem in #609

FarisZR commented 2 years ago

@fariszr Could you test it without nginx proxy manager. We had a possibliy similar problem in #609

the server it self is giving a 404.

woodpecker  | {"level":"error","time":"2021-12-17T1x:24:10Z","message":"error: FarisZR/test: cannot find  in refs/heads/main: ConfigFetcher: Fallback did not found config: 404 Not Found"}
woodpecker  | {"level":"error","error":"Error #01: ConfigFetcher: Fallback did not found config: 404 Not Found\n","ip":"172.18.0.3","latency":75.461209,"method":"POST","path":"/hook","status":404,"time":"2021-12-17T1x:24:10Z","user-agent":"Go-http-client/1.1","time":"2021-12-17T1x:24:10Z"}

it doesn't look like a proxy problem, since oauth and manual curl post requests are working fine.

FarisZR commented 2 years ago

i can confirm that woodpecker gave a 200 response with gitlab. with the exact same setup, just wiped out the data base and changed the environment to use gitlab instead of gitea.

6543 commented 2 years ago

@fariszr can you set the current location of the pipeline config in woodpercker repo settings?

FarisZR commented 2 years ago

@fariszr can you set the current location of the pipeline config in woodpercker repo settings?

this worked!, but is it going to work with a multi-pipeline setup ?

6543 commented 2 years ago

for the late answer ... yes this should make no difference