[JENKINS-60082] Show pull request title in name column
Would be good to get some thoughts on this/if this is the right approach.
Currently doing a survey on what users find useful on the Jenkins Dashboard (https://forms.gle/6XgzRshaF34kn4wLA) and quite a few of the responses list being able to show the pull request title on the dashboard as being useful (and I agree). So thought I'd take a look into that.
The plugin currently displays the pull request title as the title attribute of the link, meaning users have to hover over the PR to reveal what it is. This PR changes that so that it displays the title inline (it does this only if the title isn't null, and the title isn't the same as the name of the item).
Unsure on if this is right approach to displaying the title (no experience with working on this area of Jenkins) but in my limited testing with GitHub/GitLab it works as expected.
Testing done
- PR titles show inline with the PR number
- They only show if the title isn't null, and the title isn't the same as the name of the item
Submitter checklist
- [x] Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main 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 Jira
- [x] Link to relevant pull requests, esp. upstream and downstream changes
- [x] Ensure you have provided tests - that demonstrates feature works or fixes the issue
NB: ~have not looked at the code, but~ I am sure there have been some discussions about this in the past but I can not locate them, only the now referenced ticket.
I added a screenshot to description from my testing (also shows dark mode)
For consistency can you please send a PR for whatever sets the title for the project index page too please?
Browsed around a bit, tried setting displayName of the job to the PR title however it's overridden by https://github.com/jenkinsci/branch-api-plugin/blob/b4227cdbd5a2903adc7d5e3c7f2d67a690853392/src/main/java/jenkins/branch/MultiBranchProject.java#L2113
Haven't played too much but it appears there's a trait that can be supplied to set the display name to the PR title - maybe it'd make sense to provide a default trait or something like that.
Haven't played too much but it appears there's a trait that can be supplied to set the display name to the PR title - maybe it'd make sense to provide a default trait or something like that.
Right just change this orElse(null) I think:
https://github.com/jenkinsci/branch-api-plugin/blob/b4227cdbd5a2903adc7d5e3c7f2d67a690853392/src/main/java/jenkins/branch/MultiBranchProject.java#L2137
FWIW the traits don't look the best right now and could do with an improvement:
Job display name with fallback to name
Some have opacity lowered but not all for some reason
Job display name with fallback to name
perhaps this is all wrong (I forgot about the traits).
That is should there be a column for the ID of the PR and a column for the title of the PR (which can come from the configured traits)?
As a bonus the view should be configurable to show/hide the columns or add any other column (currently it is all hard coded?).
perhaps this is all wrong (I forgot about the traits).
I think a default trait should be added and most of this can likely be reverted in the jelly at least
That is should there be a column for the ID of the PR and a column for the title of the PR (which can come from the configured traits)?
No I don't think we want columns, sensible display names by default is what is requested here.
As a bonus the view should be configurable to show/hide the columns or add any other column (currently it is all hard coded?).
Separate to this but sure.
Updated it to default to RAW_AND_OBJECT_DISPLAY_NAME, and modified that to change the formatting to PR title (#PR number)
I've done a quick hack in this to format PRs consistently (i.e. drop the PR- prefix and replace it with a #), this should probably be done in the branch source plugins instead.
Whats with all the test failures?
Failing on prj.scheduleBuild2(0).getFuture().get(); - works when @ClassRule is changed to @Rule - very much out of my knowledge of expertise but maybe something isn't being torn down fast enough?
works when
@ClassRuleis changed to@Rule
Typically means that tests are not cleaning up after themselves, and are interfering with one another for example by trying to use the same job name.
@ClassRule is a bit faster but you have to pay more attention to maintenance.
Personal preference for me woul'd be to have the cr/pr id first then the title, e.g. #3 did some changes to x
Personal preference for me woul'd be to have the cr/pr id first then the title, e.g.
#3 did some changes to x
Mine is the other way, I will identify far clearer by the name than the number, (which is also what GitHub does):
e.g.
@jtnord could you take another look please?
Personal preference for me woul'd be to have the cr/pr id first then the title, e.g.
#3 did some changes to xMine is the other way, I will identify far clearer by the name than the number, (which is also what GitHub does)
So for display purposes I would agree with Tim, but for sorting purposes I would want them sorted by PR number (which is also what GH does!). (this is why I originally thought it would be better as 2 columns because I am not sure that the conflicting use cases can be solved here).
(fortunately 🧌 Jenkins does not at this point in time support pagination - so I can always <ctrl>+f)
🚢 ?
🚢 ?
sorry, thought you where a maintainer here as you had a green tick for the review, but forgot that was from the access you have on Jenkins as a whole :)
It seems this caused a long title of a pull request to be line-wrapped in a strange way, in Mozilla Firefox 128.3.1esr. Redacted by changing most letters to A and most digits to 1:
<tr id="job_PR-1111" class=" job-status-blue"><td data="4" class="jenkins-table__cell--tight jenkins-table__icon"><div class="jenkins-table__cell__button-wrapper"><span style="width: 24px; height: 24px; " class="build-status-icon__wrapper icon-blue icon-md"><span class="build-status-icon__outer"><svg viewBox="0 0 24 24" tooltip="Success" focusable="false" class="svg-icon " title="Success"><use href="/images/build-status/build-status-sprite.svg#build-status-static"></use></svg></span><svg viewBox="0 0 24 24" tooltip="Success" focusable="false" class="svg-icon icon-blue icon-md" title="Success"><use href="/static/bac444bb/images/build-status/build-status-sprite.svg#last-successful"></use></svg></span></div></td><td data="100" class="jenkins-table__cell--tight jenkins-table__icon healthReport" data-html-tooltip="<div class="jenkins-tooltip--table-wrapper"><table class="jenkins-table"><thead><tr><th class="jenkins-!-padding-left-0" align="center">W</th><th align="left">Description</th><th align="right">%</th></tr></thead><tbody><tr><td align="left" class="jenkins-table__cell--tight jenkins-table__icon"><div class="jenkins-table__cell__button-wrapper"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" height="512" viewBox="0 0 512 512" width="512"><line style="fill:none;stroke:var(--yellow);stroke-linecap:round;stroke-miterlimit:10;stroke-width:36px" x1="256" x2="256" y1="48" y2="96"/><line style="fill:none;stroke:var(--yellow);stroke-linecap:round;stroke-miterlimit:10;stroke-width:36px" x1="256" x2="256" y1="416" y2="464"/><line style="fill:none;stroke:var(--yellow);stroke-linecap:round;stroke-miterlimit:10;stroke-width:36px" x1="403.08" x2="369.14" y1="108.92" y2="142.86"/><line style="fill:none;stroke:var(--yellow);stroke-linecap:round;stroke-miterlimit:10;stroke-width:36px" x1="142.86" x2="108.92" y1="369.14" y2="403.08"/><line style="fill:none;stroke:var(--yellow);stroke-linecap:round;stroke-miterlimit:10;stroke-width:36px" x1="464" x2="416" y1="256" y2="256"/><line style="fill:none;stroke:var(--yellow);stroke-linecap:round;stroke-miterlimit:10;stroke-width:36px" x1="96" x2="48" y1="256" y2="256"/><line style="fill:none;stroke:var(--yellow);stroke-linecap:round;stroke-miterlimit:10;stroke-width:36px" x1="403.08" x2="369.14" y1="403.08" y2="369.14"/><line style="fill:none;stroke:var(--yellow);stroke-linecap:round;stroke-miterlimit:10;stroke-width:36px" x1="142.86" x2="108.92" y1="142.86" y2="108.92"/><circle cx="256" cy="256" r="80" style="fill:none;stroke:var(--yellow);stroke-linecap:round;stroke-miterlimit:10;stroke-width:36px"/></svg></div></td><td align="left">Test Result: 0 tests failing out of a total of 256 tests.</td><td align="right">100</td></tr><tr><td align="left" class="jenkins-table__cell--tight jenkins-table__icon"><div class="jenkins-table__cell__button-wrapper"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" height="512" viewBox="0 0 512 512" width="512"><line style="fill:none;stroke:var(--yellow);stroke-linecap:round;stroke-miterlimit:10;stroke-width:36px" x1="256" x2="256" y1="48" y2="96"/><line style="fill:none;stroke:var(--yellow);stroke-linecap:round;stroke-miterlimit:10;stroke-width:36px" x1="256" x2="256" y1="416" y2="464"/><line style="fill:none;stroke:var(--yellow);stroke-linecap:round;stroke-miterlimit:10;stroke-width:36px" x1="403.08" x2="369.14" y1="108.92" y2="142.86"/><line style="fill:none;stroke:var(--yellow);stroke-linecap:round;stroke-miterlimit:10;stroke-width:36px" x1="142.86" x2="108.92" y1="369.14" y2="403.08"/><line style="fill:none;stroke:var(--yellow);stroke-linecap:round;stroke-miterlimit:10;stroke-width:36px" x1="464" x2="416" y1="256" y2="256"/><line style="fill:none;stroke:var(--yellow);stroke-linecap:round;stroke-miterlimit:10;stroke-width:36px" x1="96" x2="48" y1="256" y2="256"/><line style="fill:none;stroke:var(--yellow);stroke-linecap:round;stroke-miterlimit:10;stroke-width:36px" x1="403.08" x2="369.14" y1="403.08" y2="369.14"/><line style="fill:none;stroke:var(--yellow);stroke-linecap:round;stroke-miterlimit:10;stroke-width:36px" x1="142.86" x2="108.92" y1="142.86" y2="108.92"/><circle cx="256" cy="256" r="80" style="fill:none;stroke:var(--yellow);stroke-linecap:round;stroke-miterlimit:10;stroke-width:36px"/></svg></div></td><td align="left">Build stability: No recent builds failed.</td><td align="right">100</td></tr></tbody></table></div>"><div class="jenkins-table__cell__button-wrapper"><a href="job/PR-1111/lastBuild" class="build-health-link jenkins-button jenkins-button--tertiary"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" height="512" viewBox="0 0 512 512" width="512"><line style="fill:none;stroke:var(--yellow);stroke-linecap:round;stroke-miterlimit:10;stroke-width:36px" x1="256" x2="256" y1="48" y2="96"></line><line style="fill:none;stroke:var(--yellow);stroke-linecap:round;stroke-miterlimit:10;stroke-width:36px" x1="256" x2="256" y1="416" y2="464"></line><line style="fill:none;stroke:var(--yellow);stroke-linecap:round;stroke-miterlimit:10;stroke-width:36px" x1="403.08" x2="369.14" y1="108.92" y2="142.86"></line><line style="fill:none;stroke:var(--yellow);stroke-linecap:round;stroke-miterlimit:10;stroke-width:36px" x1="142.86" x2="108.92" y1="369.14" y2="403.08"></line><line style="fill:none;stroke:var(--yellow);stroke-linecap:round;stroke-miterlimit:10;stroke-width:36px" x1="464" x2="416" y1="256" y2="256"></line><line style="fill:none;stroke:var(--yellow);stroke-linecap:round;stroke-miterlimit:10;stroke-width:36px" x1="96" x2="48" y1="256" y2="256"></line><line style="fill:none;stroke:var(--yellow);stroke-linecap:round;stroke-miterlimit:10;stroke-width:36px" x1="403.08" x2="369.14" y1="403.08" y2="369.14"></line><line style="fill:none;stroke:var(--yellow);stroke-linecap:round;stroke-miterlimit:10;stroke-width:36px" x1="142.86" x2="108.92" y1="142.86" y2="108.92"></line><circle cx="256" cy="256" r="80" style="fill:none;stroke:var(--yellow);stroke-linecap:round;stroke-miterlimit:10;stroke-width:36px"></circle></svg></a></div></td><td><a href="job/PR-1111/" class="model-link jenkins-table__link">AAAAA<wbr>-1111, Aaaaaaaaa AaaaaAaaAaaaaaaaaAaa<wbr>aaAaaaaaaa aaaaa aaa AAA aaaaaaaaaaa aaaaaaaa aa aaaaaaa aaaaa aaaaa <wbr>(#1111)<span class="jenkins-menu-dropdown-chevron" data-href="https://jenkins.example/job/AAAA/job/Aaaaa-Aaaaaa/view/change-requests/job/PR-1111/" aria-expanded="false"></span></a></td><td data="2024-10-28T11:16:15Z">
22 hr
<a href="job/PR-1111/lastSuccessfulBuild/" class="jenkins-table__link jenkins-table__badge model-link inside">#1<span class="jenkins-menu-dropdown-chevron" data-href="https://jenkins.example/job/AAAA/job/Aaaaa-Aaaaaa/view/change-requests/job/PR-1111/lastSuccessfulBuild/" aria-expanded="false"></span></a></td><td data="-">N/A</td><td data="767903">12 min</td><td class="jenkins-table__cell--tight"><div class="jenkins-table__cell__button-wrapper"><a tooltip="Schedule a Build with parameters for AAAAA-1111, Aaaaaaaaa AaaaaAaaAaaaaaaaaAaaaaAaaaaaaa aaaaa aaa AAA aaaaaaaaaaa aaaaaaaa aa aaaaaaa aaaaa aaaaa (#1111)" id="id756" href="job/PR-1111/build?delay=0sec" class="jenkins-button jenkins-button--tertiary jenkins-!-build-color " title="Schedule a Build with parameters for AAAAA-1111, Aaaaaaaaa AaaaaAaaAaaaaaaaaAaaaaAaaaaaaa aaaaa aaa AAA aaaaaaaaaaa aaaaaaaa aa aaaaaaa aaaaa aaaaa (#1111)"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" height="512" viewBox="0 0 512 512" width="512"><title></title><path d="M112,111V401c0,17.44,17,28.52,31,20.16l247.9-148.37c12.12-7.25,12.12-26.33,0-33.58L143,90.84C129,82.48,112,93.56,112,111Z" style="fill:none;stroke:currentColor;stroke-miterlimit:10;stroke-width:32px"></path></svg></a></div></td><td align="right">n/a</td><td data="64" data-html-tooltip="<div class="jenkins-tooltip healthReportDetails jenkins-tooltip--table-wrapper"><table class="jenkins-table"><thead><tr><th></th><th align="left">Tool</th><th align="right">Total</th></tr></thead><tbody><tr><td align="left"><svg class="icon-md" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" viewBox="0 0 512 512"><!--! Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc. --><path d="M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480L40 480c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24l0 112c0 13.3 10.7 24 24 24s24-10.7 24-24l0-112c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z" fill="currentColor"/></svg></td><td><a href="/job/AAAA/job/Aaaaa-Aaaaaa/view/change-requests/job/PR-1111//1/msbuild">MSBuild (Build) Warnings</a></td><td align="right">64</td></tr><tr><td align="left"><svg class="icon-md" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" viewBox="0 0 512 512"><!--! Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc. --><path d="M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480L40 480c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24l0 112c0 13.3 10.7 24 24 24s24-10.7 24-24l0-112c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z" fill="currentColor"/></svg></td><td><a href="/job/AAAA/job/Aaaaa-Aaaaaa/view/change-requests/job/PR-1111//1/msbuild-archive">MSBuild (Archive) Warnings</a></td><td align="right">0</td></tr></tbody></table></div>" class="healthReport issues-total" data-tooltip-interactive="true">64<div class="jenkins-tooltip healthReportDetails jenkins-tooltip--table-wrapper"><table class="jenkins-table"><thead><tr><th></th><th align="left">Tool</th><th align="right">Total</th></tr></thead><tbody><tr><td align="left"><svg class="icon-md" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" viewBox="0 0 512 512"><!--! Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc. --><path d="M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480L40 480c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24l0 112c0 13.3 10.7 24 24 24s24-10.7 24-24l0-112c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z" fill="currentColor"></path></svg></td><td><a href="/job/AAAA/job/Aaaaa-Aaaaa/view/change-requests/job/PR-1111//1/msbuild">MSBuild (Build) Warnings</a></td><td align="right">64</td></tr><tr><td align="left"><svg class="icon-md" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" viewBox="0 0 512 512"><!--! Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc. --><path d="M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480L40 480c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24l0 112c0 13.3 10.7 24 24 24s24-10.7 24-24l0-112c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z" fill="currentColor"></path></svg></td><td><a href="/job/AAAA/job/Aaaaa-Aaaaaa/view/change-requests/job/PR-1111//1/msbuild-archive">MSBuild (Archive) Warnings</a></td><td align="right">0</td></tr></tbody></table></div></td></tr>
The same HTML renders OK in Microsoft Edge 130.0.2849.56, though:
Adding a span within the a element fixes the rendering in Mozilla Firefox 128.3.1esr, and doesn't seem to hurt in Microsoft Edge 130.0.2849.56:
<td><a href="job/PR-1111/" class="model-link jenkins-table__link"><span>AAAAA<wbr>-1111, Aaaaaaaaa AaaaaAaaAaaaaaaaaAaa<wbr>aaAaaaaaaa aaaaa aaa AAA aaaaaaaaaaa aaaaaaaa aa aaaaaaa aaaaa aaaaa <wbr>(#1111)</span><span class="jenkins-menu-dropdown-chevron" data-href="https://jenkins.example/job/AAAA/job/Aaaaa-Aaaaaa/view/change-requests/job/PR-1111/" aria-expanded="false"></span></a></td>
I also tried restoring the inside class, but that did not fix the line-wrapping in Mozilla Firefox 128.3.1esr.
See https://github.com/jenkinsci/branch-api-plugin/pull/492 for the Firefox fix
FYI JENKINS-74811