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

Bitbucket Server / Data Center: List branches endpoint 404 #1695

Closed majodev closed 1 year ago

majodev commented 1 year ago

Component

server

Describe the bug

Hi,

I'm currently in the process of migrating a fairly old Bitbucket Server 7.x (non-cloud) instance to Bitbucket Data Center 8.8. As part of this, I'm also investigating migration of a super old woodpecker instance (v0.8.105) to v0.15.7 and now to next.

Apart from the typical to be expected DB migrations and breaking ENV configuration changes, the branch list integration introduced with #907 (more exactly the <base>/2.0/repositories/<owner>/<name>/refs/branches template string here) is actually something still blocking us currently. It 404s on Bitbucket Server / Data Center and consequently 500 within Woodpecker.

AFAIK for both Bitbucket Server / Data Center 7.x and 8.x (non-cloud) the proper integration endpoint should be GET <base>/rest/api/latest/projects/<owner>/repos/<name>/branches. Sample Bitbucket Response of this endpoint is:

{
    "size": 4,
    "limit": 25,
    "isLastPage": true,
    "values": [
        {
            "id": "refs/heads/dev",
            "displayId": "dev",
            "type": "BRANCH",
            "latestCommit": "<SHA>",
            "latestChangeset": "<SHA>",
            "isDefault": false
        },
        {
            "id": "refs/heads/main",
            "displayId": "main",
            "type": "BRANCH",
            "latestCommit": "<SHA>",
            "latestChangeset": "<SHA>",
            "isDefault": true
        }
    ],
    "start": 0
}

Sources:

System Info

woodpeckerci/woodpecker-server:next-e408c1ba27-alpine
{"source":"https://github.com/woodpecker-ci/woodpecker","version":"next-e408c1ba"}

Additional context

Woodpecker Server Log:

{
    "level": "error",
    "error": "Error #01: invalid character '<' looking for beginning of value\n",
    "ip": "xxx.xxx.xxx.xxx",
    "latency": 54.356947,
    "method": "GET",
    "path": "/api/repos/PROJECT/REPO/branches",
    "status": 500,
    "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36",
    "time": "2023-04-03T15:57:01Z",
    "caller": "/woodpecker/src/github.com/woodpecker-ci/woodpecker/server/router/middleware/logger.go:43"
}

Browser Console / UI:

Bildschirm­foto 2023-04-03 um 17 57 28 Bildschirm­foto 2023-04-03 um 18 00 10

Validations

qwerty287 commented 1 year ago

Do you only refer to hosted BitBucket or also to the self-hosted BitBucket Server (Stash)?

majodev commented 1 year ago

Do you only refer to hosted BitBucket

AFAIK the "cloud" variant of Bitbucket has this branches API endpoint which you currently use (I've not tested those).

or also to the self-hosted BitBucket Server (Stash)?

yes, my issue only refers to self-hosted Bitbucket (formerly Stash, available as Server or Data Center license) and the branches endpoint here.

qwerty287 commented 1 year ago

@majodev Created #1698, however, I can't test it as I don't have access to a Bitbucket server. It would be very nice if you could try :)

6543 commented 1 year ago

@majodev https://github.com/woodpecker-ci/woodpecker/pull/1698#issuecomment-1500319408