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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bitbucket Server code report fails when using subpath #1124

Closed
lgellrich opened this issue Feb 17, 2022 · 0 comments
Closed

Bitbucket Server code report fails when using subpath #1124

lgellrich opened this issue Feb 17, 2022 · 0 comments

Comments

@lgellrich
Copy link
Contributor

Hi,

I found this project just yesterday and got very curios to give it a try 馃槃
So while playing around today I got to the point where I had some reports to add to a Bitbucket Server instance from a Jenkins job.

But unfortunately I ran into the following issue:

$ export CI_PULL_REQUEST=14
$ export CI_REPO_OWNER=haya14busa
$ export CI_REPO_NAME=reviewdog
$ export CI_COMMIT=$(git rev-parse HEAD)
$ export BITBUCKET_USER="my_user"
$ export BITBUCKET_PASSWORD="my_password"
$ export BITBUCKET_SERVER_URL="https://bitbucket.my-company.com/bitbucket"
$ reviewdog -reporter=bitbucket-code-report
2022/02/16 22:15:05 reviewdog: [start]  runner=eslint
2022/02/16 22:15:05 reviewdog: [finish] runner=eslint
reviewdog: failted to delete code insights report: bitubucket API error: 405 Method Not Allowed

After cloning the project locally and enabling debugging of the Bitbucket API client I found that requests were using the wrong URL.
The calls were made to https://bitbucket.my-company.com/rest/... instead of the expected URL https://bitbucket.my-company.com/bitbucket/rest/....

The reason seems to be that the path portion is dropped within this function:

// WithServerVariables adds server variable to context
func withServerVariables(ctx context.Context, bbURL string) (context.Context, error) {
parsed, err := url.Parse(bbURL)
if err != nil {
return ctx, fmt.Errorf("failed to parse Bitbucket Server URL: %w", err)
}
return context.WithValue(
ctx,
insights.ContextServerVariables,
map[string]string{
"protocol": parsed.Scheme,
"bitbucketDomain": parsed.Host,
},
), nil
}

Unfortunately the error message does not indicate which server or at least service is used in regards to URL or Bitbucket Cloud vs. Bitbucket Server.
I suspected first that I was talking to Bitbucket Cloud by accident due to a wrong configuration.

reviewdog version: v0.14.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant