Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-72490

Discovery trait to group branches and PRs in a single location

      What I'm looking for

      Most repositories I've worked with professionally had a unique set of requirements that are currently not addressed well by this plugin. We wanted to have:

      • Build branches, except for PoCs/investigation branches
      • Specific behavior for PR builds, ex: Sonar integration to check new code only
      • A single view with all of those jobs

      We address almost all of this except for the last part.

      • We use the branch discovery trait with regex filters and branch naming convention for #1
      • We use the pull request (from origin) discovery trait with draft PR filter for #2
      • BUT: we have an issue with jobs "jumping" from the 'Branches' view to the 'Pull Requests' view when we open the PR which is pretty confusing. It also means that people searching for the builds related to a feature can't 'ctrl-f' in a single location.

      I think that finding a way to group the branch & PR jobs would be beneficial for lots of users.

      What I've tried

      I thought first that the 'Branch' and 'Pull Requests' tabs were only views and that adding a new one would be possible without duplicating the jobs but it looks like this is not how the plugin is implemented.

      From my investigation into the code, the tabs related to categories instead which look awfully like folders instead.

      I've managed to create a new mixed discovery trait linked to a new mixed category that heavily copies the branch and origin PR discovery traits but I'm not sure about this solution. You can review it in this PR

      Could you please review my use-case, and if you don't have any already working solution for it I might've missed, have a look at my code so we can discuss how to properly do it?

      The questions  I still have:

      • Is this something that has its place in this plugin or should it be an extension?
      • Is my implementation correct or is there a better way to do what I want to do?

      My branch is a PoC and everything is up to discussion, don't hesitate to point shortcomings! I've discovered the code all by myself so there must be places where my mental model is flawed.

          [JENKINS-72490] Discovery trait to group branches and PRs in a single location

          My hunch is that the single view that shows both branches and pull requests would be better implemented in scm-api or branch-api, as a UI feature for multibranch projects in general, with no dependency on GitHub and no effect on branch discovery.

          If a multibranch project has two SCM sources – say one for GitHub and another for GitLab – then the decision for whether the combined view should be shown, seems to belong to the project itself, not to any single SCM source.

          If an SCM source discovers tags too, do you want to include those in the combined view or exclude them? If it is OK to include them, then the view could be titled "All", which would not depend on the terminology used by the SCM sources ("pull requests" vs. "merge requests").

          Kalle Niemitalo added a comment - My hunch is that the single view that shows both branches and pull requests would be better implemented in scm-api or branch-api, as a UI feature for multibranch projects in general, with no dependency on GitHub and no effect on branch discovery. If a multibranch project has two SCM sources – say one for GitHub and another for GitLab – then the decision for whether the combined view should be shown, seems to belong to the project itself, not to any single SCM source. If an SCM source discovers tags too, do you want to include those in the combined view or exclude them? If it is OK to include them, then the view could be titled "All", which would not depend on the terminology used by the SCM sources ("pull requests" vs. "merge requests").

          Kalle Niemitalo added a comment - MultiBranchProjectViewHolder.ensureViews() apparently constructs a view for each SCMHeadCategory: https://github.com/jenkinsci/branch-api-plugin/blob/0b4a7964d3f1c724205bfa544882783b4ee12cb5/src/main/java/jenkins/branch/MultiBranchProjectViewHolder.java#L134-L152

          Thanks for your input kon !

          So there  were indeed views but I couldn't find where all this was done, that's interesting and I do agree that it'd be better to create an All view that would group all the categories in a single view, that was my first intention but I was limited by my knowledge of the plugins' structures.
          Your pointer is going to help me try to implement a better version of this, that's neat!

          I'll keep this issue open until I can link it to my next attempt then close it, hopefully in favor of a better implementation.

          Cyprien Quilici added a comment - Thanks for your input kon ! So there  were indeed views but I couldn't find where all this was done, that's interesting and I do agree that it'd be better to create an All view that would group all the categories in a single view, that was my first intention but I was limited by my knowledge of the plugins' structures. Your pointer is going to help me try to implement a better version of this, that's neat! I'll keep this issue open until I can link it to my next attempt then close it, hopefully in favor of a better implementation.

          Strangely, although multibranch projects do not have a "New View" link in the left sidebar, it is possible to append "newView" to the multibranch project URL and get a "New View" page that looks like it allows a view to be added… but the view created in this way is apparently not saved. Perhaps that is because MultiBranchProjectViewHolder.setViews does nothing.

          Kalle Niemitalo added a comment - Strangely, although multibranch projects do not have a "New View" link in the left sidebar, it is possible to append "newView" to the multibranch project URL and get a "New View" page that looks like it allows a view to be added… but the view created in this way is apparently not saved. Perhaps that is because MultiBranchProjectViewHolder.setViews does nothing.

          Cyprien Quilici added a comment - - edited

          I dug around and found this issue that complains that custom views have been removed in the past: https://issues.jenkins.io/browse/JENKINS-42783
          I've asked there what the rationale is behind this change.
          I tried to append /newView in the URL on the multi-branch pipeline job but got an error when I tried to save it Oo

          Cyprien Quilici added a comment - - edited I dug around and found this issue that complains that custom views have been removed in the past: https://issues.jenkins.io/browse/JENKINS-42783 I've asked there what the rationale is behind this change. I tried to append /newView in the URL on the multi-branch pipeline job but got an error when I tried to save it Oo

            Unassigned Unassigned
            quilicicf Cyprien Quilici
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: