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

Add PR naming strategy trait (#354)

Open PayBas opened this issue 4 years ago • 9 comments

This has been sitting on my PC for more than a year. Might be useful for others.

Basically it just adds a "trait" that allows pipeline admins to change the way pull request names are displayed in Jenkins. Our team found it very annoying that pull requests are simply displayed as PR-1234 instead of something resembling the originating branch name (or pull request name). Especially in build monitors it's annoying to not know what you're looking at.

To combat this problem, a new "naming strategy trait" has been added, which gives (some) control over the display names.

Resolves: https://issues.jenkins-ci.org/browse/JENKINS-55348 https://github.com/jenkinsci/bitbucket-branch-source-plugin/issues/354

I should add that we've been using this modification for about 9 months now in a project of about 100 developers. No issues so far. But our setup isn't very exotic, so no guarantees. I also don't know how this interacts with Bitbucket Cloud. We don't use it, so I haven't tried/tested it.

Your checklist for this pull request

  • [x] Make sure you are requesting to pull a topic/feature/bugfix branch (right side) and not your master branch!
  • [x] Ensure that the pull request title represents the desired changelog entry
  • [x] Please describe what you did
  • [x] Link to relevant issues in GitHub or in Jenkins JIRA
  • [x] Link to relevant pull requests, esp. upstream and downstream changes
  • [x] Did you provide a test-case? That demonstrates feature works or fixes the issue.

PayBas avatar Oct 22 '20 00:10 PayBas

Branch rebased on upstream/master and all review comments resolved. Marking this as "ready for review".

PayBas avatar Dec 30 '20 09:12 PayBas

I marked some of the javadoc as @since 2.10.0, but I don't know how this is normally determined. I don't know exactly when you guys do a minor version bump. There shouldn't be any breaking changes here, so it doesn't warrant a major bump at least.

PayBas avatar Dec 31 '20 10:12 PayBas

I wanted to open an issue just about this. Thanks for your work! Eagerly waiting for this to be merged 🚀

Semmu avatar Jan 13 '21 17:01 Semmu

Work deadlines, combined with the process of trying to buy a house is leaving me with little/no time for side-projects. @bitwiseman thank you for all the feedback. I'll respond/update as soon as I have some time to dive back in to this.

PayBas avatar Jan 14 '21 01:01 PayBas

Hi everybody, I just wanted to check about the current status of this pull request.

darxriggs avatar Jun 29 '21 11:06 darxriggs

Combining this PR with https://github.com/jenkinsci/branch-api-plugin/pull/254 and implementing it there would be even better 😀

cobexer avatar Jun 29 '21 15:06 cobexer

Hi, What's the status on this? I would love to see it merged :)

wsialex avatar Sep 22 '21 12:09 wsialex

The enums in these pull requests are pretty similar:

PullRequestNamingStrategy in https://github.com/jenkinsci/bitbucket-branch-source-plugin/pull/389 MultiBranchProjectDisplayNamingStrategy in https://github.com/jenkinsci/branch-api-plugin/pull/254
PR_ID: Use pull request ID (default) RAW: Use the name as specified by the scm connector. (traditional behaviour)
PR_ID_TITLE: Use pull request ID and title. (experimental) RAW_AND_OBJECT_DISPLAY_NAME: Use both the raw name and the display name from the ObjectMetadataAction (if available).
PR_ID_BRANCH_NAME: Use pull request ID and branch name (not implemented)
PR_TITLE: Use only pull request title. (experimental) OBJECT_DISPLAY_NAME: Use the display name (if available) sourced from the ObjectMetadataAction.
PR_BRANCH_NAME: Use only pull request branch name (not implemented)

@cobexer, when you write "combining this PR", do you mean Bitbucket Branch Source would store the PR title as-is in ObjectMetadataAction (like it already does), and the equivalents of PR_ID_BRANCH_NAME and PR_BRANCH_NAME would be added to https://github.com/jenkinsci/branch-api-plugin/pull/254?

In my comment on JENKINS-66581, I requested that Bitbucket Server Integration should likewise start adding ObjectMetadataAction. I think it would be more convenient if the naming strategies were defined just once in Branch API, rather than in each SCM integration plugin.

KalleOlaviNiemitalo avatar Sep 22 '21 13:09 KalleOlaviNiemitalo

@cobexer, when you write "combining this PR", do you mean Bitbucket Branch Source would store the PR title as-is in ObjectMetadataAction (like it already does), and the equivalents of PR_ID_BRANCH_NAME and PR_BRANCH_NAME would be added to jenkinsci/branch-api-plugin#254?

@KalleOlaviNiemitalo Yes, I think adding additional naming strategies to the branch-api-plugin is the best approach. Both mentioned strategies are out of scope for me though.

cobexer avatar Sep 28 '21 08:09 cobexer

@PayBas - What's the status of this PR? Our team is interested in implementing this into our Jenkins.

theycallmeninx avatar Nov 18 '22 15:11 theycallmeninx

Consider this PR abandoned. It has been largely supplanted by https://github.com/jenkinsci/branch-api-plugin/pull/374

While the functionality isn't completely identical and I'd rather have more options in terms of display-name rendering, it's "good enough". Besides, in case you missed it: I haven't had time to revisit this PR in years now, and I'm no longer as active in development as I used to be. So I'm closing it.

PayBas avatar Jun 16 '23 11:06 PayBas