bitbucket-branch-source-plugin icon indicating copy to clipboard operation
bitbucket-branch-source-plugin copied to clipboard

Bitbucket cloud's workspaces are not recognized

Open 375gnu opened this issue 3 years ago • 7 comments

I leave my original report, but i found that the plugin doesn't recognize workspaces and treats them as ordinal users and so role parameter is added.

Version report

Jenkins and plugins versions report:

Various. Plugin versions 2.7.0 and 2.9.8 were tested.

Reproduction steps

  • Goto bitbucket cloud
  • Create a workspace and several repositories in the workspace
  • Create a new Bitbucket Team/Project in Jenkins

Results

Expected result:

All those repositories should be listed.

Actual result:

No repositories are listed.

According to official Bitbucket API documentation (https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D):

Returns a paginated list of all repositories owned by the specified account or UUID.

The result can be narrowed down based on the authenticated user's role.

E.g. with ?role=contributor, only those repositories that the authenticated user has write access to are returned (this includes any repo the user is an admin on, as that implies write access).

This endpoint also supports filtering and sorting of the results. See filtering and sorting for more details.

So, role=owner makes sense only for a personal workspace. For organizations it should be omitted (in that case it's implicitly role=member) or made configurable (admin/contributor/member/owner).

375gnu avatar May 20 '21 11:05 375gnu

Any news on this? I'm facing the same issue.

guimarca avatar Aug 26 '21 13:08 guimarca

https://github.com/jenkinsci/bitbucket-branch-source-plugin/pull/475 changes the only occurrence of UserRoleInRepository.OWNER to UserRoleInRepository.ADMIN. Does that cover this issue?

KalleOlaviNiemitalo avatar Aug 26 '21 13:08 KalleOlaviNiemitalo

mmm ... the occurence is the one causing the issue, but changing it to ADMIN won't solve it (I'm testing agains the REST API myself). Changing it to UserRoleInRepository.MEMBER will.

guimarca avatar Aug 26 '21 13:08 guimarca

Well, in the end it depends on the role the user has on the repository. Out situation is the following: we are using bitbucket workspaces, and we have a user for jenkins tha is a member of the workspace. With this confguration and role='member', everything works. If the #475 is merged with role='admin' it will work as long as you make use jenkins bitbucket user admin in all repositories. It is less convenient that handling that with just workspace membership, but it'd work.

guimarca avatar Aug 26 '21 13:08 guimarca

Does the webhook registration require admin permissions? Although I suppose you could configure the plugin not to register it, and instead ask an admin to do it manually.

KalleOlaviNiemitalo avatar Aug 26 '21 13:08 KalleOlaviNiemitalo

I see, maybe the member role is not enough for that

guimarca avatar Aug 26 '21 14:08 guimarca

Hello, Please I need help. I have installed the bitbucket-branch-source-plugin. I added the correct credentials for bitbucket in Manage Jenkins > Configure System > Bitbucket Endpoints > Manage hooks. Then I created a multibranch pipeline and in branch sources, I selected the bitbucket cloud, and added the same credentials I added in the bitbucket endpoints (This is the correct credentials), I added the owner which is an admin account but the repository names do not display. The bitbucket cloud account is an organization account and there are over 50 repositories on it yet I can't get anyone to display in the dropdown. Please assist me with this. I am using Jenkins 2.387.1

InnocentChukwuDevOps avatar Apr 06 '23 07:04 InnocentChukwuDevOps