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

Use pull request target branch for reference build by default

XMLWordPrintable

      When Jenkins is building pull request (either the source branch or the result of merging), the discoverReferenceBuild and discoverGitReferenceBuild steps could choose a reference build from the job corresponding to the target branch of the pull request, by default. This way, the pipeline would not need to pass in defaultBranch: env.CHANGE_TARGET explicitly.

      The precedence could be:

      1. referenceJob: argument
      2. target branch of the pull request, from ChangeRequestSCMHead.getTarget()
      3. defaultBranch: argument
      4. PrimaryInstanceMetadataAction, if JENKINS-66689 is implemented
      5. hardcoded DEFAULT_BRANCH = "master"

      This could be implemented by making ReferenceRecorder in forensics-api-plugin call ChangeRequestSCMHead.getTarget() if available, and use the result as the reference branch, instead of the default branch (which can be set with ReferenceRecorder.setDefaultBranch or defaults to "master"). SimpleReferenceRecorder.setReferenceJob would still bypass the multibranch support altogether, and use exactly the job that you specify.

            drulli Ulli Hafner
            kon Kalle Niemitalo
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: