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

Unable to select a branch source when creating new multi-branch item.

    • branch-api 2.6.3, cloudbees-folder 6.15

      Clicking on a source type on a new item doesn't display the SCM form.

      After clicking the GitHub (or other source types) the dropdown menu closes and the form is not displayed.

      Expected: Click on GitHub in the Branch Sources dropdown menu and the GitHub form pops up.

       

      See attachment.

        1. image-2020-10-30-07-02-43-834.png
          image-2020-10-30-07-02-43-834.png
          48 kB
        2. Jenkins-Ticket.gif
          Jenkins-Ticket.gif
          309 kB
        3. screenshot-1.png
          screenshot-1.png
          58 kB
        4. screenshot-2.png
          screenshot-2.png
          4 kB
        5. selectSource.png
          selectSource.png
          14 kB

          [JENKINS-64069] Unable to select a branch source when creating new multi-branch item.

          Tim Jacomb added a comment -

          Tim Jacomb added a comment - reinholdfuereder I created https://issues.jenkins-ci.org/browse/JENKINS-64136

          Tim Jacomb added a comment - - edited

          The next issue occurring when saving:

          Seems to occur because of different json being submitted. note the missing source wrapper

          working:

          {
            "displayNameOrNull": "",
            "description": "",
            "disable": false,
            "sources": {
              "source": {
                "stapler-class": "jenkins.scm.impl.SingleSCMSource",
                "id": "9cca4d61-4e24-475e-bb31-7278e355e6f5",
                "name": "multibranch",
                "": "0",
                "scm": {
                  "userRemoteConfigs": {
                    "url": "https://github.com/timja-org/junit-attachments-test/",
                    "includeUser": "false",
                    "credentialsId": "",
                    "name": "",
                    "refspec": ""
                  },
                  "branches": {
                    "name": "*/master"
                  },
                  "": "auto",
                  "stapler-class": "hudson.plugins.git.GitSCM",
                  "$class": "hudson.plugins.git.GitSCM"
                }
              },
              "": "0",
              "strategy": {
                "stapler-class": "jenkins.branch.DefaultBranchPropertyStrategy",
                "$class": "jenkins.branch.DefaultBranchPropertyStrategy"
              },
              "stapler-class": "jenkins.branch.BranchSource",
              "kind": "jenkins.branch.BranchSource"
            },
            "": [
              "0",
              "1"
            ],
            "projectFactory": {
              "scriptPath": "Jenkinsfile",
              "stapler-class": "org.jenkinsci.plugins.workflow.multibranch.WorkflowBranchProjectFactory",
              "$class": "org.jenkinsci.plugins.workflow.multibranch.WorkflowBranchProjectFactory"
            },
            "orphanedItemStrategy": {
              "stapler-class": "com.cloudbees.hudson.plugins.folder.computed.DefaultOrphanedItemStrategy",
              "$class": "com.cloudbees.hudson.plugins.folder.computed.DefaultOrphanedItemStrategy",
              "pruneDeadBranches": true,
              "daysToKeepStr": "",
              "numToKeepStr": ""
            },
            "icon": {
              "stapler-class": "jenkins.branch.MetadataActionFolderIcon",
              "$class": "jenkins.branch.MetadataActionFolderIcon"
            },
            "core:apply": "",
            "Jenkins-Crumb": "52ae8303c473373a97598b65ba5b7b453cf6b0e2f5601c362001de51dbcd4d95"
          }
          

          broken:

          {
            "displayNameOrNull": "",
            "description": "",
            "disable": false,
            "sources": {
              "stapler-class": [
                "jenkins.scm.impl.SingleSCMSource",
                "jenkins.branch.BranchSource"
              ],
              "id": "d25aeca3-e276-486c-b9b4-463642963444",
              "name": "something-cool",
              "": [
                "0",
                "0"
              ],
              "scm": {
                "userRemoteConfigs": {
                  "url": "https://github.com/timja-org/junit-attachments-test",
                  "includeUser": "false",
                  "credentialsId": "",
                  "name": "",
                  "refspec": ""
                },
                "branches": {
                  "name": "*/master"
                },
                "": "auto",
                "stapler-class": "hudson.plugins.git.GitSCM",
                "$class": "hudson.plugins.git.GitSCM"
              },
              "strategy": {
                "stapler-class": "jenkins.branch.DefaultBranchPropertyStrategy",
                "$class": "jenkins.branch.DefaultBranchPropertyStrategy"
              },
              "kind": "jenkins.branch.BranchSource"
            },
            "": [
              "0",
              "1"
            ],
            "projectFactory": {
              "scriptPath": "Jenkinsfile",
              "stapler-class": "org.jenkinsci.plugins.workflow.multibranch.WorkflowBranchProjectFactory",
              "$class": "org.jenkinsci.plugins.workflow.multibranch.WorkflowBranchProjectFactory"
            },
            "orphanedItemStrategy": {
              "stapler-class": "com.cloudbees.hudson.plugins.folder.computed.DefaultOrphanedItemStrategy",
              "$class": "com.cloudbees.hudson.plugins.folder.computed.DefaultOrphanedItemStrategy",
              "pruneDeadBranches": true,
              "daysToKeepStr": "",
              "numToKeepStr": ""
            },
            "icon": {
              "stapler-class": "jenkins.branch.MetadataActionFolderIcon",
              "$class": "jenkins.branch.MetadataActionFolderIcon"
            },
            "healthMetrics": {
              "recursive": true,
              "stapler-class": "com.cloudbees.hudson.plugins.folder.health.WorstChildHealthMetric",
              "$class": "com.cloudbees.hudson.plugins.folder.health.WorstChildHealthMetric"
            },
            "core:apply": "",
            "Jenkins-Crumb": "7f9c1ca3889be930ae668727e6e8ba1ad7b74e4d83edc9604ff038312799b5cc"
          }
          

          Tim Jacomb added a comment - - edited The next issue occurring when saving: Seems to occur because of different json being submitted. note the missing source wrapper working: { "displayNameOrNull" : "", "description" : "", "disable" : false , "sources" : { "source" : { "stapler-class" : "jenkins.scm.impl.SingleSCMSource" , "id" : "9cca4d61-4e24-475e-bb31-7278e355e6f5" , "name" : "multibranch" , "": " 0", "scm" : { "userRemoteConfigs" : { "url" : "https: //github.com/timja-org/junit-attachments-test/" , "includeUser" : " false " , "credentialsId" : "", "name" : "", "refspec" : "" }, "branches" : { "name" : "*/master" }, "": " auto", "stapler-class" : "hudson.plugins.git.GitSCM" , "$class" : "hudson.plugins.git.GitSCM" } }, "": " 0", "strategy" : { "stapler-class" : "jenkins.branch.DefaultBranchPropertyStrategy" , "$class" : "jenkins.branch.DefaultBranchPropertyStrategy" }, "stapler-class" : "jenkins.branch.BranchSource" , "kind" : "jenkins.branch.BranchSource" }, "": [ "0" , "1" ], "projectFactory" : { "scriptPath" : "Jenkinsfile" , "stapler-class" : "org.jenkinsci.plugins.workflow.multibranch.WorkflowBranchProjectFactory" , "$class" : "org.jenkinsci.plugins.workflow.multibranch.WorkflowBranchProjectFactory" }, "orphanedItemStrategy" : { "stapler-class" : "com.cloudbees.hudson.plugins.folder.computed.DefaultOrphanedItemStrategy" , "$class" : "com.cloudbees.hudson.plugins.folder.computed.DefaultOrphanedItemStrategy" , "pruneDeadBranches" : true , "daysToKeepStr" : "", "numToKeepStr" : "" }, "icon" : { "stapler-class" : "jenkins.branch.MetadataActionFolderIcon" , "$class" : "jenkins.branch.MetadataActionFolderIcon" }, "core:apply" : "", "Jenkins-Crumb" : "52ae8303c473373a97598b65ba5b7b453cf6b0e2f5601c362001de51dbcd4d95" } broken: { "displayNameOrNull" : "", "description" : "", "disable" : false , "sources" : { "stapler-class" : [ "jenkins.scm.impl.SingleSCMSource" , "jenkins.branch.BranchSource" ], "id" : "d25aeca3-e276-486c-b9b4-463642963444" , "name" : "something-cool" , "": [ "0" , "0" ], "scm" : { "userRemoteConfigs" : { "url" : "https: //github.com/timja-org/junit-attachments-test" , "includeUser" : " false " , "credentialsId" : "", "name" : "", "refspec" : "" }, "branches" : { "name" : "*/master" }, "": " auto", "stapler-class" : "hudson.plugins.git.GitSCM" , "$class" : "hudson.plugins.git.GitSCM" }, "strategy" : { "stapler-class" : "jenkins.branch.DefaultBranchPropertyStrategy" , "$class" : "jenkins.branch.DefaultBranchPropertyStrategy" }, "kind" : "jenkins.branch.BranchSource" }, "": [ "0" , "1" ], "projectFactory" : { "scriptPath" : "Jenkinsfile" , "stapler-class" : "org.jenkinsci.plugins.workflow.multibranch.WorkflowBranchProjectFactory" , "$class" : "org.jenkinsci.plugins.workflow.multibranch.WorkflowBranchProjectFactory" }, "orphanedItemStrategy" : { "stapler-class" : "com.cloudbees.hudson.plugins.folder.computed.DefaultOrphanedItemStrategy" , "$class" : "com.cloudbees.hudson.plugins.folder.computed.DefaultOrphanedItemStrategy" , "pruneDeadBranches" : true , "daysToKeepStr" : "", "numToKeepStr" : "" }, "icon" : { "stapler-class" : "jenkins.branch.MetadataActionFolderIcon" , "$class" : "jenkins.branch.MetadataActionFolderIcon" }, "healthMetrics" : { "recursive" : true , "stapler-class" : "com.cloudbees.hudson.plugins.folder.health.WorstChildHealthMetric" , "$class" : "com.cloudbees.hudson.plugins.folder.health.WorstChildHealthMetric" }, "core:apply" : "", "Jenkins-Crumb" : "7f9c1ca3889be930ae668727e6e8ba1ad7b74e4d83edc9604ff038312799b5cc" }

          Félix Queiruga Balado added a comment - - edited

          I have seen these sort of problem before in this tables-to-divs work. It was related to the ability of hudson-behaviour to build a proper tree. Maybe we need to look into it.

          Félix Queiruga Balado added a comment - - edited I have seen these sort of problem before in this tables-to-divs work. It was related to the ability of hudson-behaviour to build a proper tree. Maybe we need to look into it.

          Tim Jacomb added a comment -

          seems to be because the div name="source is missing.

          it's here:
          https://github.com/jenkinsci/branch-api-plugin/blob/e69c48a1a01c210a4703fed975ca234d85743cdb/src/main/resources/jenkins/branch/BranchSource/config.jelly#L26

          and when run from hpi:run in branch-api it works but not elsewhere

          Tim Jacomb added a comment - seems to be because the div name="source is missing. it's here: https://github.com/jenkinsci/branch-api-plugin/blob/e69c48a1a01c210a4703fed975ca234d85743cdb/src/main/resources/jenkins/branch/BranchSource/config.jelly#L26 and when run from hpi:run in branch-api it works but not elsewhere

          Tim Jacomb added a comment -

          this fixes it but breaks compat with old core. Will experiment a bit more but maybe we just raise the baseline.

          $ git diff
          diff --git a/src/main/resources/jenkins/branch/BranchSource/config.jelly b/src/main/resources/jenkins/branch/BranchSource/config.jelly
          index c736737..c8f2850 100644
          --- a/src/main/resources/jenkins/branch/BranchSource/config.jelly
          +++ b/src/main/resources/jenkins/branch/BranchSource/config.jelly
          @@ -23,7 +23,7 @@
            -->
           <?jelly escape-by-default='true'?>
           <j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:branch="/lib/branch-api">
          -  <branch:rowWrapper name="source">
          +  <div class="tr" name="source" data-hack="true">
               <branch:entryWrapper>
                 <input type="hidden" name="stapler-class" value="${sourceDescriptor.clazz.name}"/>
                 <branch:blockWrapper>
          @@ -34,7 +34,7 @@
                   </j:scope>
                 </branch:blockWrapper>
               </branch:entryWrapper>
          -  </branch:rowWrapper>
          +  </div>
             <j:set var="descriptors" value="${descriptor.propertyStrategyDescriptors(it,sourceDescriptor)}"/>
             <j:if test="${!descriptors.isEmpty()}">
               <f:block>
          

          Tim Jacomb added a comment - this fixes it but breaks compat with old core. Will experiment a bit more but maybe we just raise the baseline. $ git diff diff --git a/src/main/resources/jenkins/branch/BranchSource/config.jelly b/src/main/resources/jenkins/branch/BranchSource/config.jelly index c736737..c8f2850 100644 --- a/src/main/resources/jenkins/branch/BranchSource/config.jelly +++ b/src/main/resources/jenkins/branch/BranchSource/config.jelly @@ -23,7 +23,7 @@ --> <?jelly escape-by- default = ' true ' ?> <j:jelly xmlns:j= "jelly:core" xmlns:st= "jelly:stapler" xmlns:d= "jelly:define" xmlns:l= "/lib/layout" xmlns:t= "/lib/hudson" xmlns:f= "/lib/form" xmlns:branch= "/lib/branch-api" > - <branch:rowWrapper name= "source" > + <div class= "tr" name= "source" data-hack= " true " > <branch:entryWrapper> <input type= "hidden" name= "stapler-class" value= "${sourceDescriptor.clazz.name}" /> <branch:blockWrapper> @@ -34,7 +34,7 @@ </j:scope> </branch:blockWrapper> </branch:entryWrapper> - </branch:rowWrapper> + </div> <j:set var = "descriptors" value= "${descriptor.propertyStrategyDescriptors(it,sourceDescriptor)}" /> <j: if test= "${!descriptors.isEmpty()}" > <f:block>

          If raising the baseline is acceptable I'd say go for it. What's the data-hack for, btw?

          Félix Queiruga Balado added a comment - If raising the baseline is acceptable I'd say go for it. What's the data-hack for, btw?

          Tim Jacomb added a comment -

          Just adding an attribute, making sure the jelly was getting reloaded

          Tim Jacomb added a comment - Just adding an attribute, making sure the jelly was getting reloaded

          Ok,makes sense

          Félix Queiruga Balado added a comment - Ok,makes sense

          Devin Nusbaum added a comment -

          Fixes for this issue have been released in Branch API plugin 2.6.3 and CloudBees Folder plugin 6.15.

          Devin Nusbaum added a comment - Fixes for this issue have been released in Branch API plugin 2.6.3 and CloudBees Folder plugin 6.15.

          Barel Elbaz added a comment - - edited

          A workaround that's worth a mention here, If you face with it and you need to set Branch Source urgently you can:

          1. Login to Jenkins via ssh
          2. Modify ```JENKINS_HOME/jobs/<job_name>/config.xml``` - Just copy & modify from different job with working & configured branch source

          Sample config:

          ```

              <sources class="jenkins.branch.MultiBranchProject$BranchSourceList">
                  <data>
                      <jenkins.branch.BranchSource>
                          <source class="jenkins.plugins.git.GitSCMSource">
                              <id>1100</id>
                              <remote><---YOUR REPO GOES HERE Ex:https://github.com/---></remote>
                              <credentialsId>YOUR_CREDENTIALS</credentialsId>
                              <includes>*</includes>
                              <excludes/>
                              <ignoreOnPushNotifications>false</ignoreOnPushNotifications>
                          </source>
                          <strategy class="jenkins.branch.DefaultBranchPropertyStrategy">
                              <properties class="empty-list"/>
                          </strategy>
                      </jenkins.branch.BranchSource>
                  </data>
                  <owner class="org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject" reference="../.."/>
              </sources>

          ```

          Barel Elbaz added a comment - - edited A workaround that's worth a mention here, If you face with it and you need to set Branch Source urgently you can: Login to Jenkins via ssh Modify ```JENKINS_HOME/jobs/<job_name>/config.xml``` - Just copy & modify from different job with working & configured branch source Sample config: ```     <sources class="jenkins.branch.MultiBranchProject$BranchSourceList">         <data>             <jenkins.branch.BranchSource>                 <source class="jenkins.plugins.git.GitSCMSource">                     <id>1100</id>                     <remote> <---YOUR REPO GOES HERE Ex: https://github.com/--- > </remote>                     <credentialsId> YOUR_CREDENTIALS </credentialsId>                     <includes>*</includes>                     <excludes/>                     <ignoreOnPushNotifications>false</ignoreOnPushNotifications>                 </source>                 <strategy class="jenkins.branch.DefaultBranchPropertyStrategy">                     <properties class="empty-list"/>                 </strategy>             </jenkins.branch.BranchSource>         </data>         <owner class="org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject" reference="../.."/>     </sources> ```

            timja Tim Jacomb
            wgillaspy William Gillaspy
            Votes:
            0 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved: