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

Obtain SCMHead from Item


      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.

            jglick Jesse Glick
            jglick Jesse Glick
            0 Vote for this issue
            3 Start watching this issue