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

Multibranch pipeline does not build GitHub pull requests destined for single branch

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Trivial Trivial
    • scm-api-plugin
    • None

      I have configured a multibranch job to only find a single branch (because that's what I want). Really, the only reason I'm using multi-branch at all is for pull request functionality in pipelines.

      Unfortunately, multi-branch does not appear to detect pull requests to master. Maybe because of the branch specifier? I don't consider this working as designed. The intent here is to build pull requests destined for the master branch regardless of what the branch name might be.

      I have attached a sample config.xml, a screenshot, and the indexing log from the multibranch job. Please see environment for master and plugin versions.

          [JENKINS-47091] Multibranch pipeline does not build GitHub pull requests destined for single branch

          Sam Gleske created issue -
          Sam Gleske made changes -
          Description Original: I have configured a multibranch job to only find a single branch (because that's what I want). Really, the only reason I'm using multi-branch at all is for pull request functionality in pipelines.

          Unfortunately, multi-branch does not appear to detect pull requests to master. Maybe because of the branch specifier? I don't consider this working as designed. The intent here is to build pull requests destined for the master branch regardless of what the branch name might be.

          I have attached a sample config.xml, a screenshot, and the indexing log from the multibranch job.
          New: I have configured a multibranch job to only find a single branch (because that's what I want). Really, the only reason I'm using multi-branch at all is for pull request functionality in pipelines.

          Unfortunately, multi-branch does not appear to detect pull requests to master. Maybe because of the branch specifier? I don't consider this working as designed. The intent here is to build pull requests destined for the master branch regardless of what the branch name might be.

          I have attached a sample config.xml, a screenshot, and the indexing log from the multibranch job. Please see
          Sam Gleske made changes -
          Description Original: I have configured a multibranch job to only find a single branch (because that's what I want). Really, the only reason I'm using multi-branch at all is for pull request functionality in pipelines.

          Unfortunately, multi-branch does not appear to detect pull requests to master. Maybe because of the branch specifier? I don't consider this working as designed. The intent here is to build pull requests destined for the master branch regardless of what the branch name might be.

          I have attached a sample config.xml, a screenshot, and the indexing log from the multibranch job. Please see
          New: I have configured a multibranch job to only find a single branch (because that's what I want). Really, the only reason I'm using multi-branch at all is for pull request functionality in pipelines.

          Unfortunately, multi-branch does not appear to detect pull requests to master. Maybe because of the branch specifier? I don't consider this working as designed. The intent here is to build pull requests destined for the master branch regardless of what the branch name might be.

          I have attached a sample config.xml, a screenshot, and the indexing log from the multibranch job. Please see environment for master and plugin versions.
          Sam Gleske made changes -
          Environment Original:
          dashboard-view 2.9.11
          display-url-api 2.0
          docker-commons 1.8
          docker-workflow 1.13
          durable-task 1.14
          embeddable-build-status 1.9
          external-monitor-job 1.7
          favorite 2.3.0
          git 3.5.1
          git-client 2.5.0
          git-server 1.7
          github 1.28.0
          github-api 1.86
          github-branch-source 2.2.3
          github-oauth 0.27
          groovy 2.0
          groovy-label-assignment 1.2.0
          handlebars 1.1.1
          htmlpublisher 1.14
          icon-shim 2.0.3
          jackson2-api 2.7.3
          javadoc 1.4
          jira 2.4.2
          job-dsl 1.65
          jquery-detached 1.2.1
          junit 1.21
          ldap 1.17
          mailer 1.20
          mapdb-api 1.0.9.0
          mask-passwords 2.10.1
          matrix-auth 1.7
          matrix-project 1.11
          maven-plugin 2.17
          mercurial 2.1
          momentjs 1.1.1
          pam-auth 1.3
          pipeline-build-step 2.5.1
          pipeline-graph-analysis 1.5
          pipeline-input-step 2.8
          pipeline-milestone-step 1.3.1
          pipeline-model-api 1.2
          pipeline-model-declarative-agent 1.1.1
          pipeline-model-definition 1.2
          pipeline-model-extensions 1.2
          pipeline-rest-api 2.9
          pipeline-stage-step 2.2
          pipeline-stage-tags-metadata 1.2
          pipeline-stage-view 2.9
          plain-credentials 1.4
          pubsub-light 1.12
          rich-text-publisher-plugin 1.4
          scm-api 2.2.2
          script-security 1.34
          sse-gateway 1.15
          ssh-credentials 1.13
          ssh-slaves 1.21
          structs 1.10
          subversion 2.9
          token-macro 2.3
          translation 1.15
          variant 1.1
          view-job-filters 1.27
          windows-slaves 1.3.1
          workflow-aggregator 2.5
          workflow-api 2.20
          workflow-basic-steps 2.6
          workflow-cps 2.40
          workflow-cps-global-lib 2.9
          workflow-durable-task-step 2.15
          workflow-job 2.14.1
          workflow-multibranch 2.16
          workflow-scm-step 2.6
          workflow-step-api 2.13
          workflow-support 2.14
          yet-another-docker-plugin 0.1.0-rc41
          New: Jenkins version 2.73.1
          ace-editor 1.1
          ant 1.7
          antisamy-markup-formatter 1.5
          authentication-tokens 1.3
          blueocean 1.2.4
          blueocean-autofavorite 1.0.0
          blueocean-bitbucket-pipeline 1.2.4
          blueocean-commons 1.2.4
          blueocean-config 1.2.4
          blueocean-dashboard 1.2.4
          blueocean-display-url 2.1.0
          blueocean-events 1.2.4
          blueocean-git-pipeline 1.2.4
          blueocean-github-pipeline 1.2.4
          blueocean-i18n 1.2.4
          blueocean-jira 1.2.4
          blueocean-jwt 1.2.4
          blueocean-personalization 1.2.4
          blueocean-pipeline-api-impl 1.2.4
          blueocean-pipeline-editor 1.2.4
          blueocean-pipeline-scm-api 1.2.4
          blueocean-rest 1.2.4
          blueocean-rest-impl 1.2.4
          blueocean-web 1.2.4
          bouncycastle-api 2.16.2
          branch-api 2.0.11
          cloud-stats 0.13
          cloudbees-bitbucket-branch-source 2.2.3
          cloudbees-folder 6.1.2
          cobertura 1.11
          console-column-plugin 1.5
          covcomplplot 1.1.1
          credentials 2.1.16
          credentials-binding 1.13
          cvs 2.13
          dashboard-view 2.9.11
          display-url-api 2.0
          docker-commons 1.8
          docker-workflow 1.13
          durable-task 1.14
          embeddable-build-status 1.9
          external-monitor-job 1.7
          favorite 2.3.0
          git 3.5.1
          git-client 2.5.0
          git-server 1.7
          github 1.28.0
          github-api 1.86
          github-branch-source 2.2.3
          github-oauth 0.27
          groovy 2.0
          groovy-label-assignment 1.2.0
          handlebars 1.1.1
          htmlpublisher 1.14
          icon-shim 2.0.3
          jackson2-api 2.7.3
          javadoc 1.4
          jira 2.4.2
          job-dsl 1.65
          jquery-detached 1.2.1
          junit 1.21
          ldap 1.17
          mailer 1.20
          mapdb-api 1.0.9.0
          mask-passwords 2.10.1
          matrix-auth 1.7
          matrix-project 1.11
          maven-plugin 2.17
          mercurial 2.1
          momentjs 1.1.1
          pam-auth 1.3
          pipeline-build-step 2.5.1
          pipeline-graph-analysis 1.5
          pipeline-input-step 2.8
          pipeline-milestone-step 1.3.1
          pipeline-model-api 1.2
          pipeline-model-declarative-agent 1.1.1
          pipeline-model-definition 1.2
          pipeline-model-extensions 1.2
          pipeline-rest-api 2.9
          pipeline-stage-step 2.2
          pipeline-stage-tags-metadata 1.2
          pipeline-stage-view 2.9
          plain-credentials 1.4
          pubsub-light 1.12
          rich-text-publisher-plugin 1.4
          scm-api 2.2.2
          script-security 1.34
          sse-gateway 1.15
          ssh-credentials 1.13
          ssh-slaves 1.21
          structs 1.10
          subversion 2.9
          token-macro 2.3
          translation 1.15
          variant 1.1
          view-job-filters 1.27
          windows-slaves 1.3.1
          workflow-aggregator 2.5
          workflow-api 2.20
          workflow-basic-steps 2.6
          workflow-cps 2.40
          workflow-cps-global-lib 2.9
          workflow-durable-task-step 2.15
          workflow-job 2.14.1
          workflow-multibranch 2.16
          workflow-scm-step 2.6
          workflow-step-api 2.13
          workflow-support 2.14
          yet-another-docker-plugin 0.1.0-rc41

          Your includes rule is

          master

          Which means it will only build heads with the name master

          What you want is an includes rule of

          master, PR-*

          so that heads called PR-2 etc are also allowed to be discovered

          Stephen Connolly added a comment - Your includes rule is master Which means it will only build heads with the name master What you want is an includes rule of master, PR-* so that heads called PR-2 etc are also allowed to be discovered
          Stephen Connolly made changes -
          Resolution New: Not A Defect [ 7 ]
          Status Original: Open [ 1 ] New: Closed [ 6 ]

          Sam Gleske added a comment -

          Please take a little longer to comprehend this defect. I'm challenging your assertion that it's not a defect.

          The current implementation is counter intuitive to practically every other integration with GitHub pull requests. Take for example:

          It's not just Travis CI and ghprb-plugin which interact with GitHub pull requests. I can spend all day finding and giving you examples because there's an overwhelming amount.

          The current implementation leaves a lot to be desired. The current architecture puts unnecessary burden on a development team to know and document that they have to include PR- as part of their branch name.

          Proposed fix

          Pull requests destined for the master branch, regardless of their branch name, should be automatically built (but keep the same forking vs internal PRs model).

          Sam Gleske added a comment - Please take a little longer to comprehend this defect. I'm challenging your assertion that it's not a defect. The current implementation is counter intuitive to practically every other integration with GitHub pull requests. Take for example: ghprb-plugin not requiring snowflake branch names in order to process PRs. Travis CI building pull requests despite a master whitelist ; see the .travis.yml file It's not just Travis CI and ghprb-plugin which interact with GitHub pull requests. I can spend all day finding and giving you examples because there's an overwhelming amount. The current implementation leaves a lot to be desired. The current architecture puts unnecessary burden on a development team to know and document that they have to include PR- as part of their branch name. Proposed fix Pull requests destined for the master branch, regardless of their branch name, should be automatically built (but keep the same forking vs internal PRs model).
          Sam Gleske made changes -
          Resolution Original: Not A Defect [ 7 ]
          Status Original: Closed [ 6 ] New: Reopened [ 4 ]

          What you want is an extension plugin for the GitHub Branch Source that filters in a GitHub aware way rather than the generic filter in the SCM API plugin.

          It should be fairly trivial to do: basically mostly like https://github.com/jenkinsci/scm-api-plugin/blob/master/src/main/java/jenkins/scm/impl/trait/WildcardSCMHeadFilterTrait.java you just need to split the logic at https://github.com/jenkinsci/scm-api-plugin/blob/master/src/main/java/jenkins/scm/impl/trait/WildcardSCMHeadFilterTrait.java#L99-L100 so that if it is a ChangeRequestSCMHead you instead filter on https://github.com/jenkinsci/scm-api-plugin/blob/master/src/main/java/jenkins/scm/api/mixin/ChangeRequestSCMHead.java#L57 (in fact you could probably make it a more generic extension plugin as that only needs to rely on SCM API... but it should still be an extension plugin as this is a special case filtering)

          Stephen Connolly added a comment - What you want is an extension plugin for the GitHub Branch Source that filters in a GitHub aware way rather than the generic filter in the SCM API plugin. It should be fairly trivial to do: basically mostly like https://github.com/jenkinsci/scm-api-plugin/blob/master/src/main/java/jenkins/scm/impl/trait/WildcardSCMHeadFilterTrait.java you just need to split the logic at https://github.com/jenkinsci/scm-api-plugin/blob/master/src/main/java/jenkins/scm/impl/trait/WildcardSCMHeadFilterTrait.java#L99-L100 so that if it is a ChangeRequestSCMHead you instead filter on https://github.com/jenkinsci/scm-api-plugin/blob/master/src/main/java/jenkins/scm/api/mixin/ChangeRequestSCMHead.java#L57 (in fact you could probably make it a more generic extension plugin as that only needs to rely on SCM API... but it should still be an extension plugin as this is a special case filtering)
          Stephen Connolly made changes -
          Issue Type Original: Improvement [ 4 ] New: New Feature [ 2 ]

            sag47 Sam Gleske
            sag47 Sam Gleske
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: