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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Bitbucket repository information to request to allow traits to filter by project #127

Merged
merged 1 commit into from
Aug 2, 2018

Conversation

michelzanini
Copy link
Contributor

@michelzanini michelzanini commented Jul 2, 2018

Hi,

I have written a trait to filter Bitbucket cloud projects as originally tried on PR #16.

However, it was suggested that such traits could be an extension plugin. I will implement such plugin but I need more information to be available so a trait can filter a project without doing any more additional API calls.

This changes here are adding the BitbucketRepository object to a request, that can later be filtered by a trait. I also included additional JSON fields to parse the project.

I have tested this with both Bitbucket server and cloud.
I have not added or changed any test cases as I do not see any tests testing the parts I have changed, please advise, if necessary I can add them.

Thanks.

Copy link
Member

@jetersen jetersen left a comment

Choose a reason for hiding this comment

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

Please add newline at the end of file to files that is missing it.
Please provide a unit test to the new trait filters

@stephenc
Copy link
Member

stephenc commented Jul 2, 2018

@Casz can you provide assistance on how @michelzanini can move this code into an extension plugin. I’m currently tied up on other stuff and I don’t want them getting disillusioned and abandoning their efforts.

@michelzanini This looks good, but the policy I have been following is to encourage people to put these kind of traits in an extension plugin. It shouldn’t be too hard to do, mostly just create a github repo, steal a pom.xml file (and make minor edits) and get yourself as a plugin maintainer.

@jetersen
Copy link
Member

jetersen commented Jul 2, 2018

@stephenc gotcha 😅

@michelzanini take a look the one of the following trait plugins to create an extension plugin:
https://github.com/jenkinsci/scm-trait-commit-skip-plugin
https://github.com/jenkinsci/scm-filter-aged-refs-plugin
https://github.com/jenkinsci/scm-filter-jira-validator-plugin

if you need any questions answered, please, ask away 👍

@michelzanini
Copy link
Contributor Author

Hi @stephenc ,

The problem of doing it as an extension plugins is that I won't be able to pass down the project key / name from the first request that is done to Bitbucket.
I would probably need to make yet another request to Bitbucket, and that could be a blocker for me. I am actually doing this PR because my organisation has 1200+ projects, some of them with hundreds of branches. This PR would help me scan only one project and decrease that time.
Via extension plugin, if I make two requests, it could still be slow :(

@jetersen
Copy link
Member

jetersen commented Jul 2, 2018

The edit to the JSON @michelzanini would properly be allowed in this plugin, but the filtering will have to be in the extension plugin so should be all good 👍

@michelzanini
Copy link
Contributor Author

Ok @Casz so I will move the traits out of here to an extension plugin and keep the JSON and BitbucketSCMNavigator / BitbucketSCMNavigatorRequest changes in this PR.

@jetersen
Copy link
Member

jetersen commented Jul 2, 2018

Sounds like a plan 👍

@jetersen
Copy link
Member

jetersen commented Jul 2, 2018

@michelzanini you can deploy a snapshot if use mvn deploy though it requires that you signup here: https://accounts.jenkins.io/signup and once signed up you can login here: https://repo.jenkins-ci.org/webapp/#/home and then you are allowed to mvn deploy 👍
You need to setup a settings.xml for maven, that you will most likely need for hosting the extension plugin anyway 😅 https://wiki.jenkins.io/display/JENKINS/Hosting+Plugins#HostingPlugins-Releasingtojenkins-ci.org

@jetersen jetersen mentioned this pull request Jul 2, 2018
…epository information to BitbucketSCMNavigatorRequest to allow traits to filter repositories based on which project they belong to
@michelzanini michelzanini force-pushed the filter-by-project branch 2 times, most recently from 384e2f7 to ece4a54 Compare July 6, 2018 13:23
@michelzanini michelzanini changed the title [JENKINS-34071] Added the possibility to filter using the Bitbucket Cloud project Adding Bitbucket repository information to request to allow traits to filter by project Jul 6, 2018
Copy link
Member

@jetersen jetersen left a comment

Choose a reason for hiding this comment

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

Looks awesome 👍

@michelzanini
Copy link
Contributor Author

I have changed the PR description to match the code and updated it so I can implement the extension plugin on top of this.

Copy link
Member

@stephenc stephenc left a comment

Choose a reason for hiding this comment

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

@rsandell can you review if you get a chance?

@coltrey
Copy link

coltrey commented Aug 2, 2018

@michelzanini Let me know if you'd like additional testing - I'm looking forward to this feature being available.

@michelzanini
Copy link
Contributor Author

Thanks @coltrey ,
I have the extension plugin to filter projects working locally already, but until I don't get this PR merged I can't publish it...
I believe I also will need #128 to make a temporary build available to my plugin, to be able to continue... waiting on this to be merged.

@stephenc stephenc merged commit 8c8f118 into jenkinsci:master Aug 2, 2018
@stephenc
Copy link
Member

stephenc commented Aug 2, 2018

@amuniz can you cut a release?

@michelzanini michelzanini deleted the filter-by-project branch August 2, 2018 18:35
@michelzanini
Copy link
Contributor Author

@stephenc there is a good amount of PRs that will be good to merge in this repository:
#131
#130
#128

And some others.
@amuniz , maybe you could include those on a release as well?

Thanks!

@stephenc
Copy link
Member

stephenc commented Aug 2, 2018

I don’t have time to review much

@cyrus-mc
Copy link

With this change merged and a new release of the branch source plugin released I was expecting to find the ability to filter based on projects (for BB Cloud). However I don't see any new capability to filter based on project.

@michelzanini
Copy link
Contributor Author

@cyrus-mc It will be done on a separated plugin, I am working on it. Should be out in a week or so.

@michelzanini
Copy link
Contributor Author

@cyrus-mc , @coltrey , this plugin is now released and available here:
https://plugins.jenkins.io/bitbucket-filter-project-trait

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

Successfully merging this pull request may close these issues.

5 participants