Skip to content

Feat bitbucket server support#6689

Merged
d4x1 merged 69 commits into
apache:mainfrom
ViktorGrigorov7:feat-bitbucket-server-support
Feb 16, 2024
Merged

Feat bitbucket server support#6689
d4x1 merged 69 commits into
apache:mainfrom
ViktorGrigorov7:feat-bitbucket-server-support

Conversation

@ViktorGrigorov7

Copy link
Copy Markdown
Contributor

⚠️ Pre Checklist

Please complete ALL items in this checklist, and remove before submitting

  • I have read through the Contributing Documentation.
  • I have added relevant tests.
  • I have added relevant documentation.
  • I will add labels to the PR, such as pr-type/bug-fix, pr-type/feature-development, etc.

Summary

What does this PR do?
This PR makes possible integration with the bitbucket server. It adds it to both the backend and the config ui.

Does this close any open issues?

Closes #4568

Screenshots

Screenshot 2023-12-22 at 14 36 07
Screenshot 2023-12-22 at 14 36 41

Other Information

"github.com/go-playground/validator/v10"
)

var vld *validator.Validate

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you'd better to use the latest helper. The code you are using can work, but the latest helper will be more clear and simple.
Examples: https://github.com/apache/incubator-devlake/blob/main/backend/plugins/github/api/init.go#L31

For more help about new helper, @klesh will help you.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, @klesh. I reviewed the api.DsHelper. From what I saw it makes the code cleaner in init.go but it complicates the code in other parts. For example, to retrieve a repo, even in the GitHub plugin, we have to make the database query (https://github.com/apache/incubator-devlake/blob/b6c9e6cf6aa4a0e07443c6f98eea2e7adf528e41/backend/plugins/github/api/blueprint_v200.go#L86). At least that's from my first look. Perhaps I don't understand it well enough. I'll look at it in a bit more depth. Help in any way would be appreciated :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a basic integration, similar to the one in BitBucket plugin.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, I took a glance and it seems very good to me.
However, we are testing v0.21 and it will be releasing it soon, so we are going to merge the PR as soon as the release branch is checked out.
I will take another closer look but I think the overall work is very impressive, thanks for your contribution.

if err != nil {
return nil, err
}
return &plugin.ApiResourceOutput{Body: connections, Status: http.StatusOK}, nil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// @Failure 400 {string} errcode.Error "Bad Request"
// @Failure 500 {string} errcode.Error "Internal Error"
// @Router /plugins/bitbucket_server/test [POST]
func TestConnection(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s := queryData.Search[0]
gid, searchName := getSearch(s)
// query.Set("sort", "name")
// query.Set("fields", "values.name,values.full_name,values.language,values.description,values.owner.display_name,values.created_on,values.updated_on,values.links.clone,values.links.html,pagelen,page,size")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These commented codes can be deleted directly.

@d4x1

d4x1 commented Dec 25, 2023

Copy link
Copy Markdown
Contributor

@ViktorGrigorov7
Thank you for your contribution! You have done a great job!
I think the PR is excellenct expect for some small issues. As to the code details, some latest update(such as new helpers and new APIs for a plugin) should be applied.

@d4x1

d4x1 commented Dec 25, 2023

Copy link
Copy Markdown
Contributor

IMO, there is one question I think we should disscuss:
BitBucket Cloud and BitBucket Server are regarded as one some type connection in the ConfigUI(you can see the config form for BitBucket), so I don't think it should be a sperated plugin with sperated go package(in a seperate directory).
GitHub Connection supports cloud and server version at the same time.
image
BitBucket is designed like GitHub.
image
And in this way, we can reduce lots of duplicated codes.

@ViktorGrigorov7

Copy link
Copy Markdown
Contributor Author

@d4x1 I do think it will be easier for the users to have BitBucket Cloud and BitBucket Server buttons. However the differences between BitBucket Cloud and BitBucket Server are significant. For example, the cloud version supports issues, deployments, etc. and these are not supported in the Server version. Also I don't think there's a lot of replicated code since the endpoints of the Server are very different from the Cloud.

@d4x1

d4x1 commented Jan 2, 2024

Copy link
Copy Markdown
Contributor

@d4x1 I do think it will be easier for the users to have BitBucket Cloud and BitBucket Server buttons. However the differences between BitBucket Cloud and BitBucket Server are significant. For example, the cloud version supports issues, deployments, etc. and these are not supported in the Server version. Also I don't think there's a lot of replicated code since the endpoints of the Server are very different from the Cloud.

Agreed!

@d4x1 d4x1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -1,4 +1,4 @@
#!/bin/sh

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just keep sh.

export const BitBucketConfig: IPluginConfig = {
plugin: 'bitbucket',
name: 'BitBucket',
icon: ({ color }) => <Icon fill={color} />,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not modify this, otherwise the theme color will not be applied.

Comment thread config-ui/src/release/v0.20.ts Outdated
TRANSFORMATION:
'https://devlake.apache.org/docs/v0.20/Configuration/BitBucket#step-3---adding-transformation-rules-optional',
},
BITBUCKET_SERVER: {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s not needed here either. There is no such plugin in 0.20.

@ViktorGrigorov7 ViktorGrigorov7 force-pushed the feat-bitbucket-server-support branch 3 times, most recently from 29e3855 to 258d0ae Compare February 13, 2024 14:49
@d4x1 d4x1 merged commit ea0daf4 into apache:main Feb 16, 2024
@martynvdijke

Copy link
Copy Markdown

Hi all,

Just wondering when this change will land in a new beta release?
I just upgrade to beta7 but can't see the change.
I would love to play wih this.

@klesh

klesh commented Mar 12, 2024

Copy link
Copy Markdown
Contributor

bitbucket server will be available on v1.0.0, maybe in 2 weeks.

wouldd pushed a commit to wouldd/incubator-devlake that referenced this pull request Sep 13, 2024
* feat: initial commit for bitbucket-server

* chore: remove bb-cloud code from server

Signed-off-by: Marais Van Zyl <marais@projexis.co.za>

* chore: remove more bb cloud references

Signed-off-by: Marais Van Zyl <marais@projexis.co.za>

* chore: set line ending to lf

Signed-off-by: Marais Van Zyl <marais@projexis.co.za>

* chore(bitbucket-server): spelling mistake

* chore(bitbucket-server): update swagger paths

* chore(bitbucket-server): fix migration name

* chore(bitbucket-server): renames from bitbucket

* chore: change test endpoint

* refactor: getting scopes to function

* chore: update repo/project remote search

Signed-off-by: Marais Van Zyl <marais@projexis.co.za>

* chore: update paging

* fix(bitbucket-server): remote scopes paging

* fix(bitbucket-server): remote scopes

* refactor: small changes to account for server apis

* test: update raw repository data

* test: repo test

* chore: refactor fields

* several fixes

* fix: made prs and pr comments extractable, renamed account to user (better suits bb terminology)

* fix: user convert

* fix: pr comment convertor

* fix: pr_commit_collector and pr_commit_extractor

* fix: commit collector/extractor

* feat: branch collector, fixes

* fix: made collection of commits happen across all branches

* fix: deleted build_collector - no use

* feat: bitbucket-server in ui + several fixes

* fix: renamed bitbucket-server to bitbucket_server

* fix: pr base_repo_id issue

* feat: grafana dashboard

* fix: pr collection issue

* fix: pr_collector end

* test: e2e for prs

* test: e2e for pr_commits

* fix: extraction commit author + e2e tests for commits

* fix: renamed account_convertor to user_convertor

* chore: removed dead comments

* fix: rebase issues

* fix: test connection

* refactor: using dsHelper

* fix: scope config crud

* feat: implemented transformations, removed previous transformations

* refactor: renamed migration

* chore: removed dead code

* fix: domain types, enabling tasks by default

* fix: merge commit sha for pull requests

* fix: pr commits pagination issue, remote scopes pagination

* fix: pagination fix for all collections in bitbucket_server

* fix: recollect issues

* fix: merge commit sha through activities api

* refactor: removed useless code and bumped up concurrency

* refactor: reduced repeating code

* fix: renamed bitbucket_server structs and fixed RootPkgPath for both bitbucket and bitbucket_server

* fix: remove commit sha parents

* fix: pagination issue, removed not used concurrency

* fix: conflict BitBucket

* fix: cicd detected issues

* fix: models

* fix: ui issues, linting issues, removed dead code

* fix: test issues

* fix: branches are not incremental

* fix: branches are not incremental

* fix: all collectors are now stateless

* fix: removed useless tasks

* fix: stateful collectors

---------

Signed-off-by: Marais Van Zyl <marais@projexis.co.za>
Co-authored-by: Marais Van Zyl <marais@projexis.co.za>
Co-authored-by: Lynwee <linwei.hou@merico.dev>
wouldd pushed a commit to wouldd/incubator-devlake that referenced this pull request Sep 13, 2024
* feat: initial commit for bitbucket-server

* chore: remove bb-cloud code from server

Signed-off-by: Marais Van Zyl <marais@projexis.co.za>

* chore: remove more bb cloud references

Signed-off-by: Marais Van Zyl <marais@projexis.co.za>

* chore: set line ending to lf

Signed-off-by: Marais Van Zyl <marais@projexis.co.za>

* chore(bitbucket-server): spelling mistake

* chore(bitbucket-server): update swagger paths

* chore(bitbucket-server): fix migration name

* chore(bitbucket-server): renames from bitbucket

* chore: change test endpoint

* refactor: getting scopes to function

* chore: update repo/project remote search

Signed-off-by: Marais Van Zyl <marais@projexis.co.za>

* chore: update paging

* fix(bitbucket-server): remote scopes paging

* fix(bitbucket-server): remote scopes

* refactor: small changes to account for server apis

* test: update raw repository data

* test: repo test

* chore: refactor fields

* several fixes

* fix: made prs and pr comments extractable, renamed account to user (better suits bb terminology)

* fix: user convert

* fix: pr comment convertor

* fix: pr_commit_collector and pr_commit_extractor

* fix: commit collector/extractor

* feat: branch collector, fixes

* fix: made collection of commits happen across all branches

* fix: deleted build_collector - no use

* feat: bitbucket-server in ui + several fixes

* fix: renamed bitbucket-server to bitbucket_server

* fix: pr base_repo_id issue

* feat: grafana dashboard

* fix: pr collection issue

* fix: pr_collector end

* test: e2e for prs

* test: e2e for pr_commits

* fix: extraction commit author + e2e tests for commits

* fix: renamed account_convertor to user_convertor

* chore: removed dead comments

* fix: rebase issues

* fix: test connection

* refactor: using dsHelper

* fix: scope config crud

* feat: implemented transformations, removed previous transformations

* refactor: renamed migration

* chore: removed dead code

* fix: domain types, enabling tasks by default

* fix: merge commit sha for pull requests

* fix: pr commits pagination issue, remote scopes pagination

* fix: pagination fix for all collections in bitbucket_server

* fix: recollect issues

* fix: merge commit sha through activities api

* refactor: removed useless code and bumped up concurrency

* refactor: reduced repeating code

* fix: renamed bitbucket_server structs and fixed RootPkgPath for both bitbucket and bitbucket_server

* fix: remove commit sha parents

* fix: pagination issue, removed not used concurrency

* fix: conflict BitBucket

* fix: cicd detected issues

* fix: models

* fix: ui issues, linting issues, removed dead code

* fix: test issues

* fix: branches are not incremental

* fix: branches are not incremental

* fix: all collectors are now stateless

* fix: removed useless tasks

* fix: stateful collectors

---------

Signed-off-by: Marais Van Zyl <marais@projexis.co.za>
Co-authored-by: Marais Van Zyl <marais@projexis.co.za>
Co-authored-by: Lynwee <linwei.hou@merico.dev>
wouldd pushed a commit to wouldd/incubator-devlake that referenced this pull request Sep 13, 2024
* feat: initial commit for bitbucket-server

* chore: remove bb-cloud code from server

Signed-off-by: Marais Van Zyl <marais@projexis.co.za>

* chore: remove more bb cloud references

Signed-off-by: Marais Van Zyl <marais@projexis.co.za>

* chore: set line ending to lf

Signed-off-by: Marais Van Zyl <marais@projexis.co.za>

* chore(bitbucket-server): spelling mistake

* chore(bitbucket-server): update swagger paths

* chore(bitbucket-server): fix migration name

* chore(bitbucket-server): renames from bitbucket

* chore: change test endpoint

* refactor: getting scopes to function

* chore: update repo/project remote search

Signed-off-by: Marais Van Zyl <marais@projexis.co.za>

* chore: update paging

* fix(bitbucket-server): remote scopes paging

* fix(bitbucket-server): remote scopes

* refactor: small changes to account for server apis

* test: update raw repository data

* test: repo test

* chore: refactor fields

* several fixes

* fix: made prs and pr comments extractable, renamed account to user (better suits bb terminology)

* fix: user convert

* fix: pr comment convertor

* fix: pr_commit_collector and pr_commit_extractor

* fix: commit collector/extractor

* feat: branch collector, fixes

* fix: made collection of commits happen across all branches

* fix: deleted build_collector - no use

* feat: bitbucket-server in ui + several fixes

* fix: renamed bitbucket-server to bitbucket_server

* fix: pr base_repo_id issue

* feat: grafana dashboard

* fix: pr collection issue

* fix: pr_collector end

* test: e2e for prs

* test: e2e for pr_commits

* fix: extraction commit author + e2e tests for commits

* fix: renamed account_convertor to user_convertor

* chore: removed dead comments

* fix: rebase issues

* fix: test connection

* refactor: using dsHelper

* fix: scope config crud

* feat: implemented transformations, removed previous transformations

* refactor: renamed migration

* chore: removed dead code

* fix: domain types, enabling tasks by default

* fix: merge commit sha for pull requests

* fix: pr commits pagination issue, remote scopes pagination

* fix: pagination fix for all collections in bitbucket_server

* fix: recollect issues

* fix: merge commit sha through activities api

* refactor: removed useless code and bumped up concurrency

* refactor: reduced repeating code

* fix: renamed bitbucket_server structs and fixed RootPkgPath for both bitbucket and bitbucket_server

* fix: remove commit sha parents

* fix: pagination issue, removed not used concurrency

* fix: conflict BitBucket

* fix: cicd detected issues

* fix: models

* fix: ui issues, linting issues, removed dead code

* fix: test issues

* fix: branches are not incremental

* fix: branches are not incremental

* fix: all collectors are now stateless

* fix: removed useless tasks

* fix: stateful collectors

---------

Signed-off-by: Marais Van Zyl <marais@projexis.co.za>
Co-authored-by: Marais Van Zyl <marais@projexis.co.za>
Co-authored-by: Lynwee <linwei.hou@merico.dev>
wouldd pushed a commit to wouldd/incubator-devlake that referenced this pull request Sep 13, 2024
* feat: initial commit for bitbucket-server

* chore: remove bb-cloud code from server

Signed-off-by: Marais Van Zyl <marais@projexis.co.za>

* chore: remove more bb cloud references

Signed-off-by: Marais Van Zyl <marais@projexis.co.za>

* chore: set line ending to lf

Signed-off-by: Marais Van Zyl <marais@projexis.co.za>

* chore(bitbucket-server): spelling mistake

* chore(bitbucket-server): update swagger paths

* chore(bitbucket-server): fix migration name

* chore(bitbucket-server): renames from bitbucket

* chore: change test endpoint

* refactor: getting scopes to function

* chore: update repo/project remote search

Signed-off-by: Marais Van Zyl <marais@projexis.co.za>

* chore: update paging

* fix(bitbucket-server): remote scopes paging

* fix(bitbucket-server): remote scopes

* refactor: small changes to account for server apis

* test: update raw repository data

* test: repo test

* chore: refactor fields

* several fixes

* fix: made prs and pr comments extractable, renamed account to user (better suits bb terminology)

* fix: user convert

* fix: pr comment convertor

* fix: pr_commit_collector and pr_commit_extractor

* fix: commit collector/extractor

* feat: branch collector, fixes

* fix: made collection of commits happen across all branches

* fix: deleted build_collector - no use

* feat: bitbucket-server in ui + several fixes

* fix: renamed bitbucket-server to bitbucket_server

* fix: pr base_repo_id issue

* feat: grafana dashboard

* fix: pr collection issue

* fix: pr_collector end

* test: e2e for prs

* test: e2e for pr_commits

* fix: extraction commit author + e2e tests for commits

* fix: renamed account_convertor to user_convertor

* chore: removed dead comments

* fix: rebase issues

* fix: test connection

* refactor: using dsHelper

* fix: scope config crud

* feat: implemented transformations, removed previous transformations

* refactor: renamed migration

* chore: removed dead code

* fix: domain types, enabling tasks by default

* fix: merge commit sha for pull requests

* fix: pr commits pagination issue, remote scopes pagination

* fix: pagination fix for all collections in bitbucket_server

* fix: recollect issues

* fix: merge commit sha through activities api

* refactor: removed useless code and bumped up concurrency

* refactor: reduced repeating code

* fix: renamed bitbucket_server structs and fixed RootPkgPath for both bitbucket and bitbucket_server

* fix: remove commit sha parents

* fix: pagination issue, removed not used concurrency

* fix: conflict BitBucket

* fix: cicd detected issues

* fix: models

* fix: ui issues, linting issues, removed dead code

* fix: test issues

* fix: branches are not incremental

* fix: branches are not incremental

* fix: all collectors are now stateless

* fix: removed useless tasks

* fix: stateful collectors

---------

Signed-off-by: Marais Van Zyl <marais@projexis.co.za>
Co-authored-by: Marais Van Zyl <marais@projexis.co.za>
Co-authored-by: Lynwee <linwei.hou@merico.dev>
wouldd pushed a commit to wouldd/incubator-devlake that referenced this pull request Feb 24, 2025
* feat: initial commit for bitbucket-server

* chore: remove bb-cloud code from server

Signed-off-by: Marais Van Zyl <marais@projexis.co.za>

* chore: remove more bb cloud references

Signed-off-by: Marais Van Zyl <marais@projexis.co.za>

* chore: set line ending to lf

Signed-off-by: Marais Van Zyl <marais@projexis.co.za>

* chore(bitbucket-server): spelling mistake

* chore(bitbucket-server): update swagger paths

* chore(bitbucket-server): fix migration name

* chore(bitbucket-server): renames from bitbucket

* chore: change test endpoint

* refactor: getting scopes to function

* chore: update repo/project remote search

Signed-off-by: Marais Van Zyl <marais@projexis.co.za>

* chore: update paging

* fix(bitbucket-server): remote scopes paging

* fix(bitbucket-server): remote scopes

* refactor: small changes to account for server apis

* test: update raw repository data

* test: repo test

* chore: refactor fields

* several fixes

* fix: made prs and pr comments extractable, renamed account to user (better suits bb terminology)

* fix: user convert

* fix: pr comment convertor

* fix: pr_commit_collector and pr_commit_extractor

* fix: commit collector/extractor

* feat: branch collector, fixes

* fix: made collection of commits happen across all branches

* fix: deleted build_collector - no use

* feat: bitbucket-server in ui + several fixes

* fix: renamed bitbucket-server to bitbucket_server

* fix: pr base_repo_id issue

* feat: grafana dashboard

* fix: pr collection issue

* fix: pr_collector end

* test: e2e for prs

* test: e2e for pr_commits

* fix: extraction commit author + e2e tests for commits

* fix: renamed account_convertor to user_convertor

* chore: removed dead comments

* fix: rebase issues

* fix: test connection

* refactor: using dsHelper

* fix: scope config crud

* feat: implemented transformations, removed previous transformations

* refactor: renamed migration

* chore: removed dead code

* fix: domain types, enabling tasks by default

* fix: merge commit sha for pull requests

* fix: pr commits pagination issue, remote scopes pagination

* fix: pagination fix for all collections in bitbucket_server

* fix: recollect issues

* fix: merge commit sha through activities api

* refactor: removed useless code and bumped up concurrency

* refactor: reduced repeating code

* fix: renamed bitbucket_server structs and fixed RootPkgPath for both bitbucket and bitbucket_server

* fix: remove commit sha parents

* fix: pagination issue, removed not used concurrency

* fix: conflict BitBucket

* fix: cicd detected issues

* fix: models

* fix: ui issues, linting issues, removed dead code

* fix: test issues

* fix: branches are not incremental

* fix: branches are not incremental

* fix: all collectors are now stateless

* fix: removed useless tasks

* fix: stateful collectors

---------

Signed-off-by: Marais Van Zyl <marais@projexis.co.za>
Co-authored-by: Marais Van Zyl <marais@projexis.co.za>
Co-authored-by: Lynwee <linwei.hou@merico.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

add-a-plugin This issue is to add a plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature][BitBucket] Support BitBucket server version

6 participants