In some cases an SCMSource implementation will receive a Job (branch project) from somewhere, such as a listener, and need to know which SCMHead it corresponds to. This information is not currently retrievable directly; you have to assume that every BranchProjectFactory creates children whose Job.name matches SCMHead.name, as both WorkflowMultiBranchProjectFactory and LiterateMultibranchProject.ProjectFactoryImpl in fact do, and as MultiBranchProject itself seems to require (cf. Javadoc for getOrCreateBranchItemsFor).

      Would be nicer for scm-api to include some API letting you map Item to SCMHead. The implementation in branch-api would just call BranchProjectFactory.getBranch. Thus you could reliably get this reverse mapping without a branch-api dependency.

          [JENKINS-30595] Obtain SCMHead from Item

          Jesse Glick created issue -
          Jesse Glick made changes -
          Labels Original: api New: api multibranch
          Jesse Glick made changes -
          Link New: This issue is blocking JENKINS-30744 [ JENKINS-30744 ]
          Jesse Glick made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Jesse Glick made changes -
          Assignee New: Jesse Glick [ jglick ]
          Jesse Glick made changes -
          Remote Link New: This issue links to "PR 4 (Web Link)" [ 13404 ]
          Jesse Glick made changes -
          Remote Link New: This issue links to "branch-api PR 13 (Web Link)" [ 13405 ]
          Jesse Glick made changes -
          Remote Link New: This issue links to "workflow PR 237 (Web Link)" [ 13406 ]

          Code changed in jenkins
          User: Jesse Glick
          Path:
          src/main/java/jenkins/scm/api/SCMHead.java
          http://jenkins-ci.org/commit/scm-api-plugin/401b49d02efabc050b18591528442ea924e14686
          Log:
          JENKINS-30595 API to get an SCMHead from an Item.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: src/main/java/jenkins/scm/api/SCMHead.java http://jenkins-ci.org/commit/scm-api-plugin/401b49d02efabc050b18591528442ea924e14686 Log: JENKINS-30595 API to get an SCMHead from an Item.

          Code changed in jenkins
          User: Jesse Glick
          Path:
          src/main/java/jenkins/scm/api/SCMHead.java
          http://jenkins-ci.org/commit/scm-api-plugin/f86a38a18caed9f1abc9cff70842def9817308aa
          Log:
          Merge pull request #4 from jglick/HeadByItem-JENKINS-30595

          JENKINS-30595 API to get an SCMHead from an Item

          Compare: https://github.com/jenkinsci/scm-api-plugin/compare/07a57da6c14c...f86a38a18cae

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: src/main/java/jenkins/scm/api/SCMHead.java http://jenkins-ci.org/commit/scm-api-plugin/f86a38a18caed9f1abc9cff70842def9817308aa Log: Merge pull request #4 from jglick/HeadByItem- JENKINS-30595 JENKINS-30595 API to get an SCMHead from an Item Compare: https://github.com/jenkinsci/scm-api-plugin/compare/07a57da6c14c...f86a38a18cae

            jglick Jesse Glick
            jglick Jesse Glick
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: